문제

Android에서 내 탭을 스타일하려고하는 문제가 있습니다.

오픈 소스 Android 연락처 목록 ( https://android.googlesource.com/platform/packages/apps/contacts ).

문제는 화면에 표시 될 때 연락처 응용 프로그램과 조금 다르게 보입니다.

내 탭

다음과 같이 보일 때 :

여기에 이미지 설명

배경색이 약간 다른 방법이고 텍스트 색이 다른 방법을 알 수 있습니다.

기본적으로 동일한 코드와 아이콘으로 이런 이유는 무엇입니까?

내 탭 레이아웃 코드는 다음과 같습니다.

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/tabhost"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:padding="0dp">
        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />
        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:padding="0dp" />
    </LinearLayout>
</TabHost>
.

특별한 것이 포함되어 있지 않습니다. 그리고 tabactivity는 다음과 같습니다.

public class TabbedActivity extends TabActivity implements
        TabHost.OnTabChangeListener {

    private TabHost tabHost;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        final Intent intent = getIntent();

        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.tab);

        tabHost = getTabHost();
        tabHost.setOnTabChangedListener(this);

        setupLatestTab();
        setupSavedTab();

        tabHost.setCurrentTab(0);
    }

    private void setupLatestTab() {

        Intent intent = new Intent().setClass(this, ResultsActivity.class);

        tabHost.addTab(tabHost
                .newTabSpec("latest")
                .setIndicator("Latest",
                        getResources().getDrawable(R.drawable.ic_tab_recent))
                .setContent(intent));
    }

    private void setupSavedTab() {

        Intent intent = new Intent().setClass(this, ResultsActivity.class);

        tabHost.addTab(tabHost
                .newTabSpec("saved")
                .setIndicator("Saved",
                        getResources().getDrawable(R.drawable.ic_tab_starred))
                .setContent(intent));
    }

    @Override
    public void onTabChanged(String tabId) {
        // Because we're using Activities as our tab children, we trigger
        // onWindowFocusChanged() to let them know when they're active. This may
        // seem to duplicate the purpose of onResume(), but it's needed because
        // onResume() can't reliably check if a keyguard is active.
        Activity activity = getLocalActivityManager().getActivity(tabId);
        if (activity != null) {
            activity.onWindowFocusChanged(true);
        }
    }

}
.

Drawable 폴더와 동일한 이미지를 사용하고 있습니다.

나는 tabactivity 에서 탭의 배경을 수동으로 수동으로 설정할 수 있다는 것을 알고 있습니다.

tabHost.getTabWidget().getChildAt(index).setBackgroundColor(Color.parseColor("#ff202020"));
.

그러나 연락처 앱은 어디 에서나이런 종류의 일을하지 않습니다 (대부분의 탭 코드의 대부분은 dialtactsactivity에 있음). 탭을 표시 할 때 오픈 소스 앱이 수행하는 작업을하고 싶습니다. 그리고 주소록 응용 프로그램 탭이 기본적으로 동일한 코드와 리소스를 사용하여 IM을 훨씬 잘 보입니다.

IM은 단지 사소한 무언가를 놓치는 것 같아요 ??

도움이 되었습니까?

해결책

This turned out to be a problem with my minimum android version not being specified ..

Added:

<uses-sdk android:minSdkVersion="8" />

to the androidmanifest and it worked fine. I guess it was reverting to the old tabs look and feel in earlier versions of android.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top