=============== Problem description ====================
About actionbar custom styles...
I want to customize the font style of the tab title in the actionbar, which should be added to style. xml
Android: actionbartabtextstyle? But it does not actually work.
PS1: the background color (Android: background) and font color (Android: titletextstyle) of the title column in the style. xml file are effective.
PS2: modifying the tab background color attribute (Android: backgroundstacked) in the style. xml file also takes effect.
PS3: actionbartabtextstyle is ineffective.
PS4: I am actionbar + viewpager + fragment to achieve multi-page sliding
Do you have to customize a layout and use getactionbar () to setcustomview (view v? However, the title background color and font have an effect. Even the tab background color has an effect. Why is actionbartabtexttext ineffective?
Here is the code of my style. xml file... fragment + viewpager + actionbar ..
<resources xmlns:android="http://schemas.android.com/apk/res/android"> <!-- Base application theme for API 14+. This theme completely replaces AppBaseTheme from BOTH res/values/styles.xml and res/values-v11/styles.xml on API 14+ devices. --> <style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar"> <!-- API 14 theme customizations can go here. --> </style> <style name="NoSpamActionBarTheme" parent="@android:style/android:Theme.Holo.Light.DarkActionBar"> <item name="android:actionBarStyle">@style/NoSpamActionBarStyle</item> </style> <style name="NoSpamActionBarStyle" parent="@android:style/Widget.Holo.Light.ActionBar.Solid"> <item name="android:background">@color/back_color</item> <item name="android:backgroundStacked">@color/tab_back_color</item> <item name="android:titleTextStyle">@style/NoSpamTitleStyle</item> <item name="android:actionBarTabTextStyle">@style/NoSpamTabText</item> </style> <style name="NoSpamTitleStyle"> <item name="android:textColor">@color/title_color</item> <item name="android:textSize">19sp</item> </style> <style name="NoSpamTabText" parent="@android:style/Widget.Holo.ActionBar.TabText"> <item name="android:textColor">@color/tab_text_color</item> <item name="android:textSize">18sp</item></style> </resources>
The following is the actionbar Construction Code.
/***** Install the phone blacklist tab Navigation */Public void setupphoneblacklisttab () {tab phoneblacklisttab = actionbar. newtab (); phoneblacklisttab. settext ("harassing phone"); phoneblacklisttab. settablistener (New nospamtablistener (); actionbar. addtab (phoneblacklisttab );}
Here is the color. xml
<?xml version="1.0" encoding="utf-8"?><resources> <color name="back_color">#99CC00</color> <color name="title_color">#FFFFFF</color> <color name="tab_back_color">#FFFFFF</color> <color name="tab_text_color">#000000</color> </resources>
Finally, the actual tab font should be black, but actually the default white color of darkactionbar
============= Solution 1 ======================
<Style name = "nospamactionequaleme" parent = "@ Android: style/theme. holo. Light. darkactionbar">
<Item name = "Android: actionbarstyle"> @ style/nospamactionbarstyle </item>
<Item name = "Android: titletextstyle"> @ style/nospamtitlestyle </item>
<Item name = "Android: actionbartabstyle"> @ style/myactionbartabstyle </item>
<Item name = "Android: actionbartabtextstyle"> @ style/nospamtabtext </item>
</Style>
<Style name = "nospamactionbarstyle" parent = "@ Android: style/widget. holo. Light. actionbar. Solid">
<Item name = "Android: background"> @ color/back_color </item>
<Item name = "Android: backgroundstacked"> @ color/tab_back_color </item>
</Style>
Just change it.
============= Solution 2 ======================
Reference the reply from jklwan on the second floor:
<Style name = "nospamactionequaleme" parent = "@ Android: style/theme. holo. Light. darkactionbar">
<Item name = "Android: actionbarstyle"> @ style/nospamactionbarstyle </item>
<Item name = "Android: titletextstyle"> @ style/nospamtitlestyle </item>
<Item name = "Android: actionbartabstyle"> @ style/myactionbartabstyle </item>
<Item name = "Android: actionbartabtextstyle"> @ style/nospamtabtext </item>
</Style>
<Style name = "nospamactionbarstyle" parent = "@ Android: style/widget. holo. Light. actionbar. Solid">
<Item name = "Android: background"> @ color/back_color </item>
<Item name = "Android: backgroundstacked"> @ color/tab_back_color </item>
</Style>
Just change it.
Delete the <item name = "Android: actionbartabstyle"> @ style/myactionbartabstyle </item> and test multiple items by yourself.
Ask questions about actionbar styles