2012-02-23 25 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">