Am using ViewPager and TabPageIndicator for showing multiple tabs.
I have applied all the styles also added android:theme="#style/StyledIndicators
in manifest. But still not getting desier output.
What am expecting is
but my current output is
Am i missing any thing? I have added all required images in drawebales.
And here is my style.xml
<resources>
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
<style name="PoppupMenu" parent="android:Widget.PopupMenu">
<item name="android:popupBackground">#android:color/white</item>
</style>
<style name="Widget"></style>
<style name="TextAppearance.TabPageIndicator" parent="Widget">
<!-- <item name="android:textStyle">bold</item> -->
<!-- <item name="android:textColor">#color/vpi__dark_theme</item> -->
</style>
<style name="StyledIndicators" parent="AppBaseTheme">
<item name="vpiTabPageIndicatorStyle">#style/CustomTabPageIndicator</item>
</style>
<style name="Widget.TabPageIndicator" parent="Widget">
<item name="android:gravity">center</item>
<item name="android:background">#FFFFFF</item>
<item name="android:paddingLeft">10dip</item>
<item name="android:paddingRight">10dip</item>
<item name="android:paddingTop">0dp</item>
<item name="android:paddingBottom">10dp</item>
<item name="android:textAppearance">#style/TextAppearance.TabPageIndicator</item>
<item name="android:textSize">14sp</item>
<item name="android:maxLines">1</item>
<item name="android:divider">#drawable/custom_tab_indicator_divider</item>
<item name="android:showDividers">middle</item>
<item name="android:dividerPadding">5dp</item>
<item name="android:height">40dp</item>
</style>
<style name="CustomTabPageIndicator" parent="Widget.TabPageIndicator">
<item name="android:background">#drawable/custom_tab_indicator</item>
<item name="android:textColor">#218801</item>
<item name="android:textSize">14sp</item>
<item name="android:divider">#drawable/custom_tab_indicator_divider</item>
<item name="android:showDividers">middle</item>
<item name="android:fadingEdge">horizontal</item>
<item name="android:fadingEdgeLength">8dp</item>
</style>
and custom_tab_indicator.xml is
<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/custom_tab_indicator_unselected" />
<item android:state_focused="false" android:state_selected="true" android:state_pressed="false" android:drawable="#drawable/custom_tab_indicator_selected" />
<!-- Focused states -->
<item android:state_focused="true" android:state_selected="false" android:state_pressed="false" android:drawable="#drawable/custom_tab_indicator_unselected_focused" />
<item android:state_focused="true" android:state_selected="true" android:state_pressed="false" android:drawable="#drawable/custom_tab_indicator_focused" />
<!-- Pressed -->
<!-- Non focused states -->
<item android:state_focused="false" android:state_selected="false" android:state_pressed="true" android:drawable="#drawable/custom_tab_indicator_unselected_pressed" />
<item android:state_focused="false" android:state_selected="true" android:state_pressed="true" android:drawable="#drawable/custom_tab_indicator_selected_pressed" />
<!-- Focused states -->
<item android:state_focused="true" android:state_selected="false" android:state_pressed="true" android:drawable="#drawable/custom_tab_indicator_unselected_pressed" />
<item android:state_focused="true" android:state_selected="true" android:state_pressed="true" android:drawable="#drawable/custom_tab_indicator_selected_pressed" />
Related
I use the code below to change the style of a tabbed activity in my application:
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
<item name="actionBarStyle">#style/ActionBarTheme</item>
</style>
<!-- Action Bar them -->
<style name="ActionBarTheme" parent="#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="background">#drawable/ab_solid_appolo</item>
<item name="backgroundSplit">#drawable/ab_bottom_solid_appolo</item>
<item name="titleTextStyle">#style/ActionBarText</item>
<item name="icon">#drawable/ic_action_launcher</item>
<item name="actionBarTabStyle">#style/ActionBarTabStyle.Appolo</item>
</style>
<style name="ActionBarText" parent="#style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">#000000</item>
</style>
<!-- ActionBar tabs styles -->
<style name="ActionBarTabStyle.Appolo" parent="#style/Widget.AppCompat.Light.ActionBar.TabView">
<item name="background">#drawable/actionbar_tab_indicator</item>
</style>
This is the actionbar_tab_indicator content:
<?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" />
<!-- 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 also use the code below for styles in style-v11 and style-v14:
...
<style name="ActionBarTheme" parent="#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="background">#drawable/ab_solid_appolo</item>
<item name="backgroundSplit">#drawable/ab_bottom_solid_appolo</item>
<item name="android:titleTextStyle">#style/ActionBarText</item>
<item name="android:icon">#drawable/ic_action_launcher</item>
<item name="android:actionBarTabStyle">#style/ActionBarTabStyle.Appolo</item>
</style>
<style name="ActionBarText" parent="#style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">#000000</item>
</style>
<!-- ActionBar tabs styles -->
<style name="ActionBarTabStyle.Appolo" parent="#style/Widget.AppCompat.Light.ActionBar.TabView">
<item name="android:background">#drawable/actionbar_tab_indicator</item>
</style>
...
But it is not changing the style of the tab bar.
I checked my code many times, I searched and reviewed all my notes but I can't find what the problem is. Does anyone have any answers?
The problem was in this part of code:
<style name="ActionBarTheme" parent="#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="background">#drawable/ab_solid_appolo</item>
<item name="backgroundSplit">#drawable/ab_bottom_solid_appolo</item>
<item name="titleTextStyle">#style/ActionBarText</item>
<item name="icon">#drawable/ic_action_launcher</item>
<item name="actionBarTabStyle">#style/ActionBarTabStyle.Appolo</item>
and especially this line:
<item name="actionBarTabStyle">#style/ActionBarTabStyle.Appolo</item>
this line should not be in the custom them that I want to use as my action bar theme. The right way is adding this under my custom app them so I remove this line from above part and add it under AppBaseTheme:
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
<item name="actionBarStyle">#style/ActionBarTheme</item>
<item name="actionBarTabStyle">#style/ActionBarTabStyle.Appolo</item>
</style>
and now the code is working right.
Write this in your style xml file.
<item name="actionBarTabStyle">#style/CustomActionBarTabs </item>
<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>
Try this:
<style name="ActionBarTheme" parent="#style/Theme.AppCompat.Light">
<item name="android:actionBarStyle">#style/ActionBarTheme.ActionBarStyle</item>
</style>
<style name="ActionBarTheme.ActionBarStlye" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#drawable/ab_solid_appolo</item>
<item name="android:backgroundSplit">#drawable/ab_bottom_solid_appolo</item>
<item name="android:titleTextStyle">#style/ActionBarTheme.ActionBar.TitleTextStyle</item>
<item name="android:icon">#drawable/ic_action_launcher</item>
<item name="android:actionBarTabStyle">#style/ActionBarTheme.ActionBar.TabStyle</item>
</style>
<style name="ActionBarTheme.ActionBar.TitleTextStyle" parent="#style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#000000</item>
</style>
<!-- ActionBar tabs styles -->
<style name="ActionBarTheme.ActionBar.TabStyle" parent="#style/Widget.Holo.Light.ActionBar">
<item name="android:background">#drawable/actionbar_tab_indicator</item>
</style>
Also make sure you're using your theme in the AndroidManifest.xml
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/ActionBarTheme" >
I have noticed, with older versions of Android, the app crashes if the Theme is not a child of AppCompat. This should be a work around.
EDIT: you also forgot to put android: before background, icon, etc.
Make sure that You have applied app-theme in manifest file.
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/MyTheme"
android:uiOptions="splitActionBarWhenNarrow" >
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>
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" />
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.
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>