0

タブホストのデフォルトの青色を赤色に変更したい。

<style name="AppTheme" parent="android:Theme.Light.NoTitleBar">
          <item name="android:tabWidgetStyle">@drawable/tab_indicator_holo</item>
          </style>

tab_indicator_holo.xml

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <!-- Non focused states -->
    <item android:state_focused="false" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/tab_unselected_holo" />
    <item android:state_focused="false" android:state_selected="true"  android:state_pressed="false" android:drawable="@drawable/tab_selected_holo" />

    <!-- Focused states -->
    <item android:state_focused="true" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/tab_unselected_focused_holo" />
    <item android:state_focused="true" android:state_selected="true"  android:state_pressed="false" android:drawable="@drawable/tab_selected_focused_holo" />

    <!-- Pressed -->
    <!--    Non focused states -->
    <item android:state_focused="false" android:state_selected="false" android:state_pressed="true" android:drawable="@drawable/tab_unselected_pressed_holo" />
    <item android:state_focused="false" android:state_selected="true"  android:state_pressed="true" android:drawable="@drawable/tab_selected_pressed_holo" />

    <!--    Focused states -->
    <item android:state_focused="true" android:state_selected="false" android:state_pressed="true" android:drawable="@drawable/tab_unselected_pressed_holo" />
    <item android:state_focused="true" android:state_selected="true"  android:state_pressed="true" android:drawable="@drawable/tab_selected_pressed_holo" />
</selector>

ただし、タブ スタイルはタブホストに適用されません。デフォルトの青は赤に変更されません。

私はこれを取得しています

ここに画像の説明を入力

アイデアや提案をお願いします。

4

1 に答える 1

5

あなたはすでに答えを見つけているかもしれませんが、同じ問題に直面している可能性がある人のために、これが私がやったことです.

  1. カスタム ホロ テーマに移動し、tabwget を yes に設定して、好みの色を選択します。

  2. zip をダウンロードし、プロジェクトにコピーします。

  3. tab_indicator_holo をインフレートして作成されたビューで tabadapter に追加します。

    View mIndicator = inflater.inflate(R.layout.tab_indicator_holo, mTabHost.getTabWidget(), false);
    TextView title1 = (TextView) mIndicator.findViewById(android.R.id.title);

    title1.setText("TAB1");

    mTabsAdapter.addTab(mTabHost.newTabSpec("TAB1").setIndicator( mIndicator), FRAGMENT1.class, null);

    View mIndicator2 = inflater.inflate(R.layout.tab_indicator_holo,      mTabHost.getTabWidget(), false);
    TextView title2 = (TextView) mIndicator2.findViewById(android.R.id.title);

    title2.setText("TAB2");
    mTabsAdapter.addTab(mTabHost.newTabSpec("TAB2").setIndicator(mIndicator2), FRAGMENT2.class, null);
于 2013-08-21T08:04:07.747 に答える