ViewPagerIndicator doesn't show underline in Tab - android

I want to make simple TabPagerIndicator, but It doesn't show a underline, I use xml to change the style. This is my xml style file:
<!-- Application theme. -->
<style name="AppTheme" parent="#style/Theme.AppCompat.Light">
<item name="vpiTitlePageIndicatorStyle">#style/CustomTitlePageIndicator</item>
<item name="vpiUnderlinePageIndicatorStyle">#style/CustomUnderlinePageIndicator</item>
<item name="vpiTabPageIndicatorStyle">#style/CustomTabPageIndicator</item>
</style>
<style name="CustomTabPageIndicator" parent="Widget.TabPageIndicator">
<item name="android:background">#color/fondo_activity</item>
<item name="android:textAppearance">#style/CustomTabPageIndicator.Text</item>
<item name="android:textColor">#FF555555</item>
<item name="android:textSize">14sp</item>
<item name="android:dividerPadding">10dp</item>
<item name="showDividers">middle</item>
<item name="android:paddingLeft">8dp</item>
<item name="android:paddingRight">8dp</item>
<item name="android:fadingEdge">horizontal</item>
<item name="android:fadingEdgeLength">8dp</item>
</style>
<style name="CustomTabPageIndicator.Text" parent="android:TextAppearance.Medium">
<item name="android:typeface">monospace</item>
</style>
<style name="CustomUnderlinePageIndicator">
<item name="selectedColor">#FFCC0000</item>
<item name="android:background">#FFCCCCCC</item>
<item name="fadeLength">1000</item>
<item name="fadeDelay">1000</item>
</style>
<style name="CustomTitlePageIndicator">
<item name="android:background">#18FF0000</item>
<item name="footerColor">#FFAA2222</item>
<item name="footerLineHeight">1dp</item>
<item name="footerIndicatorHeight">3dp</item>
<item name="footerIndicatorStyle">underline</item>
<item name="android:textColor">#AA000000</item>
<item name="selectedColor">#FF000000</item>
<item name="selectedBold">true</item>
</style>
In this picture you can see how it is shown (the red line on the top is part of the action bar)
Does anyone knows where is the error and How can I solve it?
Best.

You can set the underline with the background property. Set it to an XML drawable that defines which drawables/9-patches are used to draw the different states.
<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="#drawable/vpi__tab_unselected_holo" />
<item android:state_focused="false" android:state_selected="true" android:state_pressed="false" android:drawable="#drawable/vpi__tab_selected_holo" />
<!-- Focused states -->
<item android:state_focused="true" android:state_selected="false" android:state_pressed="false" android:drawable="#drawable/vpi__tab_unselected_focused_holo" />
<item android:state_focused="true" android:state_selected="true" android:state_pressed="false" android:drawable="#drawable/vpi__tab_selected_focused_holo" />
<!-- Pressed -->
<!-- Non focused states -->
<item android:state_focused="false" android:state_selected="false" android:state_pressed="true" android:drawable="#drawable/vpi__tab_unselected_pressed_holo" />
<item android:state_focused="false" android:state_selected="true" android:state_pressed="true" android:drawable="#drawable/vpi__tab_selected_pressed_holo" />
<!-- Focused states -->
<item android:state_focused="true" android:state_selected="false" android:state_pressed="true" android:drawable="#drawable/vpi__tab_unselected_pressed_holo" />
<item android:state_focused="true" android:state_selected="true" android:state_pressed="true" android:drawable="#drawable/vpi__tab_selected_pressed_holo" />
</selector>

Related

How to change Tab Style and Color using AppCompat Library

I am making a small program in which i am using Fragment Tabs with swipe, to make it stylish i used Style Generator, and my experience was good with that.
Now i wanna do a small change in existing look of my Tabs, this time i am talking about Tab Text style.
first view screen shot of my simple stylish ActionBar
Like we can see all Tab's text are looking equivalent, so here i need your help, in my case text style for selected Tab will remain same white as bold as it is looking, but want to change text style for others as normal (i mean those are not selected like:- IOS and WINDOWS)
styles.xml:
<resources>
<style name="Theme.Compatstyle4" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="actionBarItemBackground">#drawable/selectable_background_compatstyle4</item>
<item name="popupMenuStyle">#style/PopupMenu.Compatstyle4</item>
<item name="dropDownListViewStyle">#style/DropDownListView.Compatstyle4</item>
<item name="actionBarTabStyle">#style/ActionBarTabStyle.Compatstyle4</item>
<item name="actionDropDownStyle">#style/DropDownNav.Compatstyle4</item>
<item name="actionBarStyle">#style/ActionBar.Solid.Compatstyle4</item>
<item name="actionModeBackground">#drawable/cab_background_top_compatstyle4</item>
<item name="actionModeSplitBackground">#drawable/cab_background_bottom_compatstyle4</item>
<item name="actionModeCloseButtonStyle">#style/ActionButton.CloseMode.Compatstyle4</item>
<!-- Light.DarkActionBar specific -->
<item name="actionBarWidgetTheme">#style/Theme.Compatstyle4.Widget</item>
</style>
<style name="ActionBar.Solid.Compatstyle4" parent="#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="background">#drawable/ab_solid_compatstyle4</item>
<item name="backgroundStacked">#drawable/ab_stacked_solid_compatstyle4</item>
<item name="backgroundSplit">#drawable/ab_bottom_solid_compatstyle4</item>
<item name="progressBarStyle">#style/ProgressBar.Compatstyle4</item>
</style>
<style name="ActionBar.Transparent.Compatstyle4" parent="#style/Widget.AppCompat.ActionBar">
<item name="background">#drawable/ab_transparent_compatstyle4</item>
<item name="progressBarStyle">#style/ProgressBar.Compatstyle4</item>
</style>
<style name="PopupMenu.Compatstyle4" parent="#style/Widget.AppCompat.PopupMenu">
<item name="android:popupBackground">#drawable/menu_dropdown_panel_compatstyle4</item>
</style>
<style name="DropDownListView.Compatstyle4" parent="#style/Widget.AppCompat.ListView.DropDown">
<item name="android:listSelector">#drawable/selectable_background_compatstyle4</item>
</style>
<style name="ActionBarTabStyle.Compatstyle4" parent="#style/Widget.AppCompat.ActionBar.TabView">
<item name="android:background">#drawable/tab_indicator_ab_compatstyle4</item>
</style>
<style name="DropDownNav.Compatstyle4" parent="#style/Widget.AppCompat.Spinner.DropDown.ActionBar">
<item name="android:background">#drawable/spinner_background_ab_compatstyle4</item>
<item name="android:popupBackground">#drawable/menu_dropdown_panel_compatstyle4</item>
<item name="android:dropDownSelector">#drawable/selectable_background_compatstyle4</item>
</style>
<style name="ProgressBar.Compatstyle4" parent="#style/Widget.AppCompat.ProgressBar.Horizontal">
<item name="android:progressDrawable">#drawable/progress_horizontal_compatstyle4</item>
</style>
<style name="ActionButton.CloseMode.Compatstyle4" parent="#style/Widget.AppCompat.ActionButton.CloseMode">
<item name="android:background">#drawable/btn_cab_done_compatstyle4</item>
</style>
<!-- this style is only referenced in a Light.DarkActionBar based theme -->
<style name="Theme.Compatstyle4.Widget" parent="#style/Theme.AppCompat">
<item name="popupMenuStyle">#style/PopupMenu.Compatstyle4</item>
<item name="dropDownListViewStyle">#style/DropDownListView.Compatstyle4</item>
</style>
</resources>
Like: I want to show text color as default for selected tab and gray for others
You will need to do settings in three places.
Your ActionBAr theme, where I set my tabstyle as a custom one defined below.
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
<item name="actionBarTabStyle">#style/CustomActionBarTabs</item>
<item name="actionBarTabTextStyle">#style/CustomActionBarTabs_TextColor</item>
My custom tab style which refers to a drawable selector for various states.
<!-- action bar tab styles -->
<style name="CustomActionBarTabs" parent="#style/Widget.AppCompat.ActionBar.TabView">
<item name="android:background">#drawable/tab_indicator_ab_custom_actionbar_style</item>
<item name="android:textColor">#666666</item>
</style>
My selector, set this as per your requirement.
<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_custom_actionbar_style" />
<!-- Focused states -->
<item android:state_focused="true" android:state_selected="false" android:state_pressed="false" android:drawable="#drawable/tab_unselected_focused_custom_actionbar_style" />
<item android:state_focused="true" android:state_selected="true" android:state_pressed="false" android:drawable="#drawable/tab_selected_focused_custom_actionbar_style" />
<!-- Pressed -->
<!-- Non focused states -->
<item android:state_focused="false" android:state_selected="false" android:state_pressed="true" android:drawable="#drawable/tab_unselected_pressed_custom_actionbar_style" />
<item android:state_focused="false" android:state_selected="true" android:state_pressed="true" android:drawable="#drawable/tab_selected_pressed_custom_actionbar_style" />
<!-- Focused states -->
<item android:state_focused="true" android:state_selected="false" android:state_pressed="true" android:drawable="#drawable/tab_unselected_pressed_custom_actionbar_style" />
<item android:state_focused="true" android:state_selected="true" android:state_pressed="true" android:drawable="#drawable/tab_selected_pressed_custom_actionbar_style" />
</selector>
<!-- Focused states -->
<item android:state_focused="true" android:state_selected="false" android:state_pressed="false" android:drawable="#drawable/tab_unselected_focused_holo" />
<item android:state_focused="true" android:state_selected="true" android:state_pressed="false" android:drawable="#drawable/tab_selected_focused_holo" />
<!-- Pressed -->
<!-- Non focused states -->
<item android:state_focused="false" android:state_selected="false" android:state_pressed="true" android:drawable="#drawable/tab_unselected_pressed_holo" />
<item android:state_focused="false" android:state_selected="true" android:state_pressed="true" android:drawable="#drawable/tab_selected_pressed_holo" />
<!-- Focused states -->
<item android:state_focused="true" android:state_selected="false" android:state_pressed="true" android:drawable="#drawable/tab_unselected_pressed_holo" />
<item android:state_focused="true" android:state_selected="true" android:state_pressed="true" android:drawable="#drawable/tab_selected_pressed_holo" />

How to customize ActionBar Tab

With Android Studio I'm trying to customize my tab with Android Action Bar Style Generator but the changes weren't applied and I don't know why. I also followed the tutorial on Android Developers. I don't know how to go ahead. Can you help me please? I've been trying to do this for weeks.
This is my styles.xml:
<style name="Theme.Example" parent="#style/Theme.AppCompat.Light">
<item name="actionBarItemBackground">#drawable/selectable_background_example</item>
<item name="popupMenuStyle">#style/PopupMenu.Example</item>
<item name="dropDownListViewStyle">#style/DropDownListView.Example</item>
<item name="actionBarTabStyle">#style/ActionBarTabStyle.Example</item>
<item name="actionDropDownStyle">#style/DropDownNav.Example</item>
<item name="actionBarStyle">#style/ActionBar.Solid.Example</item>
<item name="actionModeBackground">#drawable/cab_background_top_example</item>
<item name="actionModeSplitBackground">#drawable/cab_background_bottom_example</item>
<item name="actionModeCloseButtonStyle">#style/ActionButton.CloseMode.Example</item>
</style>
<style name="ActionBar.Solid.Example" parent="#style/Widget.AppCompat.Light.ActionBar.Solid">
<item name="background">#drawable/ab_solid_example</item>
<item name="backgroundStacked">#drawable/ab_stacked_solid_example</item>
<item name="backgroundSplit">#drawable/ab_bottom_solid_example</item>
<item name="progressBarStyle">#style/ProgressBar.Example</item>
</style>
<style name="ActionBar.Transparent.Example" parent="#style/Widget.AppCompat.Light.ActionBar">
<item name="background">#drawable/ab_transparent_example</item>
<item name="progressBarStyle">#style/ProgressBar.Example</item>
</style>
<style name="PopupMenu.Example" parent="#style/Widget.AppCompat.Light.PopupMenu">
<item name="android:popupBackground">#drawable/menu_dropdown_panel_example</item>
</style>
<style name="DropDownListView.Example" parent="#style/Widget.AppCompat.Light.ListView.DropDown">
<item name="android:listSelector">#drawable/selectable_background_example</item>
</style>
<style name="ActionBarTabStyle.Example" parent="#style/Widget.AppCompat.Light.ActionBar.TabView">
<item name="android:background">#drawable/tab_indicator_ab_example</item>
<item name="background">#drawable/tab_indicator_ab_example</item>
</style>
<style name="DropDownNav.Example" parent="#style/Widget.AppCompat.Light.Spinner.DropDown.ActionBar">
<item name="android:background">#drawable/spinner_background_ab_example</item>
<item name="android:popupBackground">#drawable/menu_dropdown_panel_example</item>
<item name="android:dropDownSelector">#drawable/selectable_background_example</item>
</style>
<style name="ProgressBar.Example" parent="#style/Widget.AppCompat.ProgressBar.Horizontal">
<item name="android:progressDrawable">#drawable/progress_horizontal_example</item>
</style>
<style name="ActionButton.CloseMode.Example" parent="#style/Widget.AppCompat.Light.ActionButton.CloseMode">
<item name="android:background">#drawable/btn_cab_done_example</item>
</style>
<!-- this style is only referenced in a Light.DarkActionBar based theme -->
<style name="Theme.Example.Widget" parent="#style/Theme.AppCompat">
<item name="popupMenuStyle">#style/PopupMenu.Example</item>
<item name="dropDownListViewStyle">#style/DropDownListView.Example</item>
</style>
and this is my selector.xml:
<?xml version="1.0" encoding="utf-8"?>
<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>
(At the end all I want to do is change the indicator color like this)
You have to apply the theme in your manifest like this:
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
...
<application
android:theme="#style/Theme.Example"> <!-- Add the android:theme attribute to the application tag -->
....
EDIT
API > 14 uses the android: namespace for the ActionBar in it, while the Compat lib doesn't use it.
values\styles.xml:
<style name="Theme.Example" parent="#style/Theme.AppCompat.Light">
<item name="actionBarItemBackground">#drawable/selectable_background_example</item>
<item name="popupMenuStyle">#style/PopupMenu.Example</item>
<item name="dropDownListViewStyle">#style/DropDownListView.Example</item>
<item name="actionBarTabStyle">#style/ActionBarTabStyle.Example</item>
<item name="actionDropDownStyle">#style/DropDownNav.Example</item>
<item name="actionBarStyle">#style/ActionBar.Solid.Example</item>
<item name="actionModeBackground">#drawable/cab_background_top_example</item>
<item name="actionModeSplitBackground">#drawable/cab_background_bottom_example</item>
<item name="actionModeCloseButtonStyle">#style/ActionButton.CloseMode.Example</item>
</style>
values-v14\styles.xml:
<style name="Theme.Example" parent="#style/Theme.AppCompat.Light">
<item name="android:actionBarItemBackground">#drawable/selectable_background_example</item>
<item name="android:popupMenuStyle">#style/PopupMenu.Example</item>
<item name="android:dropDownListViewStyle">#style/DropDownListView.Example</item>
<item name="android:actionBarTabStyle">#style/ActionBarTabStyle.Example</item>
<item name="android:actionDropDownStyle">#style/DropDownNav.Example</item>
<item name="android:actionBarStyle">#style/ActionBar.Solid.Example</item>
<item name="android:actionModeBackground">#drawable/cab_background_top_example</item>
<item name="android:actionModeSplitBackground">#drawable/cab_background_bottom_example</item>
<item name="android:actionModeCloseButtonStyle">#style/ActionButton.CloseMode.Example</item>
</style>
See values vs values-v14 on Android Developers.

no resource found for #style/Widget.Holo.ActionBar.TabView

I'm trying to customize my ActionBar's tab indicator following this reference, however I'm getting the error:
Error retrieving parent for item: No resource found that matches the given name '#style/Widget.Holo.ActionBar.TabView'.
Minimum SDK is set to 14, target SDK = 18. Any ideas?
EDIT:
I already have the following styles which 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>
You should be referencing
#android:style/Widget.Holo.ActionBar.TabView
Typo in the docs - they left off the android:.
This is what you need to do:
Create a Style for your app:
Here I am customizing the Tab Bar and it's text (I am using a base compatibility theme but you can use HOLO or anything you like):
<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 those 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 the color and drawables, you can create a selector that allows the tab to change based on clicks and selection:
File: res/color/ab_tab_txt (I am using the color file from res/values to set my constants, but you can place the color like so: #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>
File res/drawable/tab_indicator
<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 drawable files are NinePatches that I create using this useful tool:
http://jgilfelt.github.io/android-actionbarstylegenerator/

How to change the color of tab 'underbar' in actionbarsherlock

Ok i'm loosing more sanity then ever. I can't find/understand how to style the damn thing.
I managed to change the background of the tab itself but I can't cahnge the color of the bar under the selected tab.
How to change it from blue to something.
My styles.xml unfortunately I have very bad understanding of how it works
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Styled" parent="Theme.Sherlock.Light">
<item name="actionBarTabStyle">#style/Widget.Styled.ActionBarTab</item>
<item name="android:actionBarTabStyle">#style/Widget.Styled.ActionBarTab</item>
<item name="actionBarTabBarStyle">#style/Widget.Styled.ActionBarTabBar</item>
<item name="android:actionBarTabBarStyle">#style/Widget.Styled.ActionBarTabBar</item>
<item name="actionBarTabTextStyle">#style/myText</item>
<item name="android:actionBarTabTextStyle">#style/myText</item>
</style>
<style name="Widget.Styled.ActionBarTab" parent="Widget.Sherlock.Light.ActionBar.TabView">
<!-- <item name="background">#drawable/startbcg</item>
<item name="android:background">#drawable/startbcg</item>
<item name="backgroundSplit">#drawable/bg_striped_split</item>
<item name="android:backgroundSplit">#drawable/bg_striped_split</item>
-->
</style>
<style name="Widget.Styled.ActionBarTabBar" parent="Widget.Sherlock.Light.ActionBar.TabBar">
<item name="background">#drawable/startbcg</item>
<item name="android:background">#drawable/startbcg</item>
<item name="backgroundSplit">#drawable/bg_striped_split</item>
<item name="android:backgroundSplit">#drawable/bg_striped_split</item>
</style>
<style name="myText" parent="Widget.Sherlock.Light.ActionBar.TabText">
<item name="android:textAppearance">#android:style/TextAppearance.Medium</item>
<item name="android:textColor">#android:color/primary_text_dark</item>
<item name="android:textSize">10sp</item>
</style>
<style name="myTextInv" parent="Widget.Sherlock.Light.ActionBar.TabText.Inverse">
<item name="android:textAppearance">#android:style/TextAppearance.Medium</item>
<item name="android:textColor">#android:color/primary_text_dark</item>
<item name="android:textSize">10sp</item>
</style>
</resources>
Bonus question: where I can find what properties (like background) certain stuff has.
Use ActionbarStyleGenerator to style the Actionbar. This is by far the simplest and most intuitive way.
How to:
Use the UI to select colors for different items
Once done click on "DOWNLOAD .ZIP"
The ZIP file contains resource files that you have to copy in your project res/layout and
res/drawableXXXX folders
I found that for the background it's better to copy the drawables (9 patches and xml) found on the Android SDK res directory and change it to have the color you like.
They use a background with the bottom bar included, so I don't think it's possible to change the bottom bar alone.
Here's what I have, working with green color for the bottom bar:
<style name="customTabStyle" parent="Widget.Sherlock.ActionBar.TabView">
<item name="android:showDividers">none</item>
<item name="android:measureWithLargestChild">true</item>
<!-- This was a copy from the sdk drawable -->
<item name="android:background">#drawable/tab_indicator</item>
<item name="background">#drawable/tab_indicator</item>
<item name="android:gravity">center</item>
<item name="android:textStyle">normal</item>
</style>
<style name="customTabBar" parent="Widget.Sherlock.ActionBar.TabBar">
<item name="android:showDividers">middle</item>
<item name="android:divider">#drawable/tab_divider</item>
<item name="divider">#drawable/tab_divider</item>
<item name="android:dividerPadding">10dip</item>
<item name="android:background">#drawable/tab_bg</item>
</style>
The tab indicator looks like this:
<?xml version="1.0" encoding="utf-8"?>
<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="#drawable/tab_unselected" />
<item android:state_focused="false" android:state_selected="true" android:state_pressed="false" android:drawable="#drawable/tab_selected" />
<!-- Focused states -->
<item android:state_focused="true" android:state_selected="false" android:state_pressed="false" android:drawable="#drawable/tab_unselected_focused" />
<item android:state_focused="true" android:state_selected="true" android:state_pressed="false" android:drawable="#drawable/tab_selected_focused" />
<!-- Pressed -->
<!-- Non focused states -->
<item android:state_focused="false" android:state_selected="false" android:state_pressed="true" android:drawable="#drawable/tab_unselected_pressed" />
<item android:state_focused="false" android:state_selected="true" android:state_pressed="true" android:drawable="#drawable/tab_selected_pressed" />
<!-- Focused states -->
<item android:state_focused="true" android:state_selected="false" android:state_pressed="true" android:drawable="#drawable/tab_unselected_pressed" />
<item android:state_focused="true" android:state_selected="true" android:state_pressed="true" android:drawable="#drawable/tab_selected_pressed" />
</selector>
I hope it helps!

Android - ActionBarSherlock - Set textcolor of text in submenu

How can i set the color of text in submenu of Action Bar Sherlock ? I can set the background but not the textcolor.. =(
temas.xml
<style name="Tema.Laranja" parent="Theme.Sherlock.Light.ForceOverflow">
<item name="actionBarItemBackground">#drawable/background_selecionado</item>
<item name="android:actionBarItemBackground">#drawable/background_selecionado</item>
<item name="android:dropDownListViewStyle">#style/Tema.Laranja.ListSelector</item>
<item name="dropDownListViewStyle">#style/Tema.Laranja.ListSelector</item>
<item name="popupMenuStyle">#style/Tema.Laranja.Popup</item>
<item name="android:popupMenuStyle">#style/Tema.Laranja.Popup</item>
</style>
<style name="Tema.Laranja.Popup" parent="Widget.Sherlock.Light.PopupMenu">
<item name="android:popupBackground">#drawable/shape_laranja_arredondado</item>
</style>
<style name="Tema.Laranja.ListSelector" parent="Widget.Sherlock.ListView.DropDown">
<item name="android:listSelector">#color/listview_actionbar</item>
<item name="android:textColor">#color/branca</item>
<item name="android:drawSelectorOnTop">true</item>
</style>
My listview_actionbar.xml
<item android:state_focused="false"
android:drawable="#drawable/shape_amarelo_arredondado"/>
<!-- Even though these two point to the same resource, have two states so the drawable will invalidate itself when coming out of pressed state. -->
<item android:state_focused="true" android:state_enabled="false"
android:state_pressed="true"
android:drawable="#drawable/shape_amarelo_arredondado" />
<item android:state_focused="true" android:state_enabled="false"
android:drawable="#drawable/shape_amarelo_arredondado" />
<item android:state_focused="true" android:state_pressed="true"
android:drawable="#drawable/shape_amarelo_arredondado" />
<item android:state_focused="false" android:state_pressed="true"
android:drawable="#drawable/shape_amarelo_arredondado" />
<item android:state_focused="true"
android:drawable="#drawable/shape_amarelo_arredondado" />
<style name="MyPopupMenu" parent="Widget.Sherlock.ListPopupWindow">
<item name="android:popupBackground">#drawable/dropdown_selector</item>
<item name="android:textAppearance">#style/TextAppearance.Sherlock.Widget.PopupMenu</item>
</style>
<style name="TextAppearance.Sherlock.Widget.PopupMenu" parent="Widget">
<item name="android:textColor">#color/branco</item>
</style>
Try using
<item name="android:textAppearanceLargePopupMenu">
<!-- #style/some style that has android:textColor as attribute -->
</item> <!-- in Tema.Laranja style -->
Use actionBarWidgetTheme and android:textColor.
Example:
<style name="Theme.Guide" parent="Theme.Sherlock.Light.DarkActionBar">
<item name="android:actionBarWidgetTheme">#style/ActionBar.Widget.Guide</item>
<item name="actionBarWidgetTheme">#style/ActionBar.Widget.Guide</item>
</style>
<style name="ActionBar.Widget.Guide" parent="Widget.Sherlock.ActionBar.Solid">
<item name="android:textColor">#android:color/white</item>
<item name="android:textSize">#dimen/action_bar_dropdown_menu_text_size</item>
</style>

Categories

Resources