Resource not found for @ style / Widget.Holo.ActionBar.TabView

I am trying to customize the ActionBar tab indicator after this link, however I am getting an error:

Error retrieving parent for item: No resource found that matches the given name '@style/Widget.Holo.ActionBar.TabView'. 

The minimum SDK is set to 14, the target SDK = 18. Any ideas?

EDIT:

I already have the following styles that work:

  <style name="sMain" parent="@android:style/Theme.Holo"> <item name="android:icon">@android:color/transparent</item> <item name="android:actionBarStyle">@style/MyActionBar</item> <item name="android:actionBarDivider">@null</item> </style> <style name="MyActionBar" parent="android:Widget.Holo.ActionBar"> <item name="android:actionBarDivider">@null</item> </style> 
+7
android android styles
source share
2 answers

You must reference

 @android:style/Widget.Holo.ActionBar.TabView 

The docs say they settled on android:

+31
source share

This is what you need to do:

Create a style for your application: Here I customize the tab bar and text (I use a basic compatibility theme, but you can use HOLO or whatever):

  <style name="AppTheme" parent="Theme.AppCompat.Light"> <item name="android:actionBarTabTextStyle">@style/TabTextStyle</item> <item name="android:actionBarTabStyle">@style/TabBarStyle</item> <!-- Support library compatibility (ActionBarCompat) --> <item name="actionBarTabTextStyle">@style/TabTextStyle</item> <item name="actionBarTabStyle">@style/TabBarStyle</item> </style> 

Create these styles:

 <style name="TabTextStyle" parent="@style/Widget.AppCompat.ActionBar.TabText"> <item name="android:textColor">@color/ab_tab_txt</item> </style> <style name="TabBarStyle" parent="@style/Widget.AppCompat.ActionBar.TabView"> <item name="android:background">@drawable/tab_indicator</item> </style> 

For color and pictures, you can create a selector that allows you to change the tab based on clicks and selections:

File: res / color / ab_tab_txt (I use the color file from res / values ​​to set my constants, but you can put it like this: #FFF)

  <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_selected="true" android:color="@color/ab_tab_txt_selected"/> <item android:color="@color/ab_tab_txt_unselected"/> </selector> 

Res / drawable / tab_indicator file

 <selector xmlns:android="http://schemas.android.com/apk/res/android"> <!-- Non focused states --> <item android:state_focused="false" android:state_selected="false" android:state_pressed="false" android:drawable="@android:color/transparent" /> <item android:state_focused="false" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/tab_selected_example" /> <!-- Focused states --> <item android:state_focused="true" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/tab_unselected_focused_example" /> <item android:state_focused="true" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/tab_selected_focused_example" /> <!-- Pressed --> <!-- Non focused states --> <item android:state_focused="false" android:state_selected="false" android:state_pressed="true" android:drawable="@drawable/tab_unselected_pressed_example" /> <item android:state_focused="false" android:state_selected="true" android:state_pressed="true" android:drawable="@drawable/tab_selected_pressed_example" /> <!-- Focused states --> <item android:state_focused="true" android:state_selected="false" android:state_pressed="true" android:drawable="@drawable/tab_unselected_pressed_example" /> <item android:state_focused="true" android:state_selected="true" android:state_pressed="true" android:drawable="@drawable/tab_selected_pressed_example" /> </selector> 

My available files are NinePatches, which I create with this useful tool: http://jgilfelt.imtqy.com/android-actionbarstylegenerator/

+1
source share

All Articles