Android タブのデフォルトの背景色を変更したい。Appcelerator フレームワークでアプリを作成しています。しかし、タブ スタイルを変更するには、やはり xml ファイルを作成する必要があります。したがって、ネイティブの Android 開発者もおそらく私を助けてくれるでしょう。
とにかく、次のxmlコードを作成しました:
<?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"
android:background="@drawable/tab_selector" >
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="0dp"
android:layout_weight="1" />
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0" />
</LinearLayout>
</TabHost>
そこで、フォルダー内background
を参照して、を指定しようとします。tab_selector.xml
drawable
タブも下部に配置されるため、xml の一部が機能することはわかっています。
次に、tab_selector.xml
私は持っています:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape>
<gradient
android:endColor="#ffffff"
android:startColor="#AAAAAA"
android:angle="270" />
<stroke
android:width="1px"
android:color="#000000" />
</shape>
</item>
<item
android:state_selected="false"
android:state_focused="false"
android:state_pressed="false">
<shape>
<gradient
android:endColor="#ffffff"
android:startColor="#AAAAAA"
android:angle="270" />
<stroke
android:width="1px"
android:color="#000000" />
</shape>
</item>
<!-- and the other states. They are the same as the ones above -->
...
...
...
</selector>
しかし、アプリを実行すると、古い元のタブ スタイルが必要になります。タブのスタイルが適用されない理由は何ですか??