2012-02-23 61 views
2

我在我的styles.xml文件中爲TabWidget定義了自定義樣式,以更改我的應用程序中的所有TabWidget背景。Style.xml中的樣式TabWidget背景

<item name="android:tabWidgetStyle">@style/CustomTabWidget</item> 
<style name="CustomTabWidget" parent="@android:style/Widget.TabWidget"> 
    <item name="android:background">@drawable/tab_bg</item> 
</style> 

在應用程序背景保持不變。自定義ListView樣式的類似定義可以正常工作。如果我在佈局中設置TabWidget背景,它將起作用。

<TabWidget 
android:id="@android:id/tabs" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:background="@drawable/tab_bg" /> 

如何使tabWidget背景從styles.xml中設置?

回答

2

您是否將您的android:tabWidgetStyle項目放入您在清單中定義的自定義主題中?

styles.xml:

<style name="CustomTheme" parent="Theme.Holo.Light"> 
    <item name="android:tabWidgetStyle">@style/LightTabWidget</item> 
</style> 

的AndroidManifest.xml:

<application android:name="yourappname" 
      android:label="@string/app_name" 
      android:icon="@drawable/logo" 
      android:theme="@style/CustomTheme">