[英]Why my custom style are not applied in the action bar?
我在搜索很多方法來自定義操作欄。
基本上,我需要為操作欄提供顏色,文本顏色,並為操作欄的導航選項卡(它們在操作欄下方)提供顏色,文本顏色,下划線顏色。
因此,我准備了以下XML樣式文件。 您可以看到,在第二個塊中,所有對文本樣式和導航選項卡樣式的引用
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="MyTheme.ActionBar" parent="@android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">@style/MyActionBar</item>
</style>
<!-- ActionBar styles: inherit the parent theme and override it with other themes -->
<style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#6b3f8f</item> <!-- #5b327c -->
<!-- <item name="android:titleTextStyle">@style/MyActionBarTitleText</item> -->
<item name="android:actionBarTabStyle">@style/tabStyle</item>
</style>
<!-- ActionBar title text -->
<style name="MyActionBarTitleText" parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#FFFFFF</item>
</style>
<!-- navigations tabs styles -->
<style name="tabStyle" parent="@android:style/Widget.Holo.Light.ActionBar.TabView">
<item name="android:background">#000000</item>
<item name="android:backgroundStacked">#000000</item>
<item name="android:backgroundSplit">#000000</item>
</style>
ActionBar的顏色在變化,而其他顏色沒有變化,為什么? 我認為已經很好地擴展了屬性。 這是我的清單:
<!-- @android:style/Theme.Holo.Light -->
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/MyTheme.ActionBar"
android:allowBackup="true">
.....
</aplication>
android:backgroundStacked
和android:backgroundSplit
應該放在MyActionBar
下,而不是您的標簽樣式下,因為它們都是Widget.Holo.ActionBar
繼承。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.