I want to customize the up button, I am using appcompat library for my actionbar. I don't want the default up button which android provides. Because I am using actionbar that has produced by style generator. So that up button looks pale with the color of actionbar that I selected. Can someone please suggest me how to achieve it? I have searched lot but couldn't find.
I have prepared my own image for it. So I want to replace that with my image. I believe it is possible. Because googleplay displays the actionbar with up button in different color in the apps section.
Below is the styles.xml:
<style name="Theme.Customab" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="actionBarItemBackground">#drawable/selectable_background_customab</item>
<item name="popupMenuStyle">#style/PopupMenu.Customab</item>
<item name="dropDownListViewStyle">#style/DropDownListView.Customab</item>
<item name="actionBarTabStyle">#style/ActionBarTabStyle.Customab</item>
<item name="actionDropDownStyle">#style/DropDownNav.Customab</item>
<item name="actionBarStyle">#style/ActionBar.Solid.Customab</item>
<item name="actionModeBackground">#drawable/cab_background_top_customab</item>
<item name="actionModeSplitBackground">#drawable/cab_background_bottom_customab</item>
<item name="actionModeCloseButtonStyle">#style/ActionButton.CloseMode.Customab</item>
<!-- Light.DarkActionBar specific -->
<item name="actionBarWidgetTheme">#style/Theme.Customab.Widget</item>
**<item name="android:homeAsUpIndicator">#drawable/customup</item>**
</style>
<style name="ActionBar.Solid.Customab" parent="#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="background">#drawable/ab_solid_customab</item>
<item name="backgroundStacked">#drawable/ab_stacked_solid_customab</item>
<item name="backgroundSplit">#drawable/ab_bottom_solid_customab</item>
<item name="progressBarStyle">#style/ProgressBar.Customab</item>
</style>
<style name="ActionBar.Transparent.Customab" parent="#style/Widget.AppCompat.ActionBar">
<item name="background">#drawable/ab_transparent_customab</item>
<item name="progressBarStyle">#style/ProgressBar.Customab</item>
</style>
<style name="PopupMenu.Customab" parent="#style/Widget.AppCompat.PopupMenu">
<item name="android:popupBackground">#drawable/menu_dropdown_panel_customab</item>
</style>
<style name="DropDownListView.Customab" parent="#style/Widget.AppCompat.ListView.DropDown">
<item name="android:listSelector">#drawable/selectable_background_customab</item>
</style>
<style name="ActionBarTabStyle.Customab" parent="#style/Widget.AppCompat.ActionBar.TabView">
<item name="android:background">#drawable/tab_indicator_ab_customab</item>
</style>
<style name="DropDownNav.Customab" parent="#style/Widget.AppCompat.Spinner.DropDown.ActionBar">
<item name="android:background">#drawable/spinner_background_ab_customab</item>
<item name="android:popupBackground">#drawable/menu_dropdown_panel_customab</item>
<item name="android:dropDownSelector">#drawable/selectable_background_customab</item>
</style>
<style name="ProgressBar.Customab" parent="#style/Widget.AppCompat.ProgressBar.Horizontal">
<item name="android:progressDrawable">#drawable/progress_horizontal_customab</item>
</style>
<style name="ActionButton.CloseMode.Customab" parent="#style/Widget.AppCompat.ActionButton.CloseMode">
<item name="android:background">#drawable/btn_cab_done_customab</item>
</style>
<!-- this style is only referenced in a Light.DarkActionBar based theme -->
<style name="Theme.Customab.Widget" parent="#style/Theme.AppCompat">
<item name="popupMenuStyle">#style/PopupMenu.Customab</item>
<item name="dropDownListViewStyle">#style/DropDownListView.Customab</item>
</style>
Adding this item to your custom theme that is related with pre-Honeycomb will give an error because that attribute does not exist in the Android framework on older devices.
<item name="android:homeAsUpIndicator">#drawable/action_up_caret</item>
Instead of "android:homeAsUpIndicator" you should override "homeAsUpIndicator" attribute in your custom theme if you are using AppCompat library.
<item name="homeAsUpIndicator">#drawable/action_up_caret</item>
Note: Here's the AppCompat source if you're interested. https://github.com/android/platform_frameworks_support/tree/master/v7/appcompat or https://android.googlesource.com/platform/frameworks/support/+/master/v7/appcompat/
Here is some of the files of the my test project:
values\styles_example.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Example" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="android: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>
<!-- Light.DarkActionBar specific -->
<item name="actionBarWidgetTheme">#style/Theme.Example.Widget</item>
<item name="homeAsUpIndicator">#drawable/ic_launcher</item>
</style>
<style name="ActionBar.Solid.Example" parent="#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<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.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.PopupMenu">
<item name="android:popupBackground">#drawable/menu_dropdown_panel_example</item>
</style>
<style name="DropDownListView.Example" parent="#style/Widget.AppCompat.ListView.DropDown">
<item name="android:listSelector">#drawable/selectable_background_example</item>
</style>
<style name="ActionBarTabStyle.Example" parent="#style/Widget.AppCompat.ActionBar.TabView">
<item name="android:background">#drawable/tab_indicator_ab_example</item>
</style>
<style name="DropDownNav.Example" parent="#style/Widget.AppCompat.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.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>
</resources>
values-v14\styles_example.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Example" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<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>
<!-- Light.DarkActionBar specific -->
<item name="android:actionBarWidgetTheme">#style/Theme.Example.Widget</item>
<item name="android:homeAsUpIndicator">#drawable/ic_launcher</item>
</style>
<style name="ActionBar.Solid.Example" parent="#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background">#drawable/ab_solid_example</item>
<item name="android:backgroundStacked">#drawable/ab_stacked_solid_example</item>
<item name="android:backgroundSplit">#drawable/ab_bottom_solid_example</item>
<item name="android:progressBarStyle">#style/ProgressBar.Example</item>
</style>
<style name="ActionBar.Transparent.Example" parent="#style/Widget.AppCompat.ActionBar">
<item name="android:background">#drawable/ab_transparent_example</item>
<item name="android:progressBarStyle">#style/ProgressBar.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="android:popupMenuStyle">#style/PopupMenu.Example</item>
<item name="android:dropDownListViewStyle">#style/DropDownListView.Example</item>
</style>
</resources>
This way should able to able to get a look like this in your activity.
Keep your image in drawable folder
specify attribute .
android:logo
Because ActionBar will use the android:logo attribute of your manifest, if one is provided. That lets you use separate drawable resources for the icon (Launcher) and the logo (ActionBar, among other things).
I've not used AppCompat, but it's pretty simple(but hard to find out) on Android 4.0.
You need to add the following item to your Application theme XML.
<item name="android:homeAsUpIndicator">#drawable/action_up_caret</item>
Related
i am trying to change the design of an existing app with a new design given by client, the app is none but Q-Municate from Quickblox, the exisitng design is old and using ActionBar, i want to replace everything with the latest Material Design, Adding AppCompact v7 Lib 23,causes affect and errors to some other libraries , so i am using AppCompact v7 19
A Good tutorial or step by step guideline would be appreciated. Thanks in advance
I am pasting my styles.xml
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<item name="android:actionBarStyle">#style/MyActionBar</item>
<item name="android:actionModeStyle">#style/MyActionMode</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar" parent="android:Widget.ActionBar">
<item name="android:background">#color/action_bar_background_color</item>
<item name="android:displayOptions">showTitle</item>
<item name="android:titleTextStyle">#style/MyActionBarTitleText</item>
<item name="android:indeterminateProgressStyle">#style/IndeterminateProgressStyle</item>
</style>
<!-- ActionBar title body -->
<style name="MyActionBarTitleText" parent="android:TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#color/white</item>
</style>
<style name="AppTheme.NoActionBar" parent="android:Theme.Holo.Light.NoActionBar">
<item name="android:windowNoTitle">true</item>
</style>
<style name="MyActionMode">
<item name="android:actionModeCloseDrawable">#drawable/badge_action_mode</item>
<item name="android:actionModeBackground">#drawable/badge_action_mode</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:titleTextStyle">#style/MyActionModeTitleText</item>
</style>
<style name="MyActionModeTitleText" parent="android:TextAppearance.Holo.Widget.ActionMode.Title">
<item name="android:textColor">#color/white</item>
</style>
<style name="baseToggleBtn">
<item name="android:textOff"></item>
<item name="android:textOn"></item>
</style>
<!-- EmojiTabs styles -->
<style name="EmojiTabImageButton" parent="android:Widget.ImageButton">
<item name="android:background">#drawable/tab_emoji_selector</item>
<item name="android:layout_width">0dip</item>
<item name="android:layout_height">match_parent</item>
<item name="android:layout_weight">1</item>
</style>
<!-- Avatars ImageView style -->
<style name="AvatarImageView">
<item name="android:layout_width">#dimen/image_view_big_avatar_layout_width</item>
<item name="android:layout_height">#dimen/image_view_big_avatar_layout_height</item>
<item name="android:layout_gravity">center|top</item>
<item name="android:scaleType">centerCrop</item>
<item name="android:src">#drawable/placeholder_user</item>
</style>
<style name="IndeterminateProgressStyle" parent="#android:style/Widget.ProgressBar">
<item name="android:minHeight">24dp</item>
<item name="android:maxHeight">24dp</item>
<item name="android:minWidth">32dp</item>
<item name="android:maxWidth">32dp</item>
</style>
<style name="DoneCancelBar">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">#dimen/action_bar_height</item>
<item name="android:orientation">horizontal</item>
<item name="android:divider">#drawable/ic_action_divider</item>
<item name="android:showDividers" tools:ignore="NewApi">middle</item>
<item name="android:dividerPadding" tools:ignore="NewApi">12dp</item>
<item name="android:background">#color/action_button_bar</item>
</style>
<style name="ActionButton">
<item name="android:layout_width">0dp</item>
<item name="android:layout_height">match_parent</item>
<item name="android:layout_weight">1</item>
<item name="android:background">#drawable/action_selectable_background</item>
</style>
<style name="ActionButtonText">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_gravity">center</item>
<item name="android:gravity">center_vertical</item>
<item name="android:paddingRight">20dp</item>
<!-- Offsets left drawable -->
<item name="android:drawablePadding">8dp</item>
<item name="android:textColor">#color/action_button_text</item>
<item name="android:textStyle">bold</item>
<item name="android:textSize">13sp</item>
</style>
<style name="ActionButtonText.Done">
<item name="android:drawableLeft">#drawable/ic_action_done</item>
<item name="android:text">#string/dlg_done</item>
</style>
<style name="ActionButtonText.Cancel">
<item name="android:drawableLeft">#drawable/ic_action_cancel</item>
<item name="android:text">#string/dlg_cancel</item>
</style>
On the previsualicer of the mobile phone, you can choose the theme here and choose material (dark or light)
I have a problem with my holo theme, it works right until Android 4.4 but when i run the same app in Android 5.0+ the dropdown menu for overflow items in the actionbar show the TEXT in color Black, i need the color WHITE
ANY IDEAS?
<style name="Theme.Flux" parent="#android:style/Theme.Holo.Light.DarkActionBar">
<item name="android:actionBarItemBackground">#drawable/selectable_background_flux</item>
<item name="android:popupMenuStyle">#style/PopupMenu.Flux</item>
<item name="android:dropDownListViewStyle">#style/DropDownListView.Flux</item>
<item name="android:actionBarTabStyle">#style/ActionBarTabStyle.Flux</item>
<item name="android:actionDropDownStyle">#style/DropDownNav.Flux</item>
<item name="android:actionBarStyle">#style/ActionBar.Solid.Flux</item>
<item name="android:actionModeBackground">#drawable/cab_background_top_flux</item>
<item name="android:actionModeSplitBackground">#drawable/cab_background_bottom_flux</item>
<item name="android:actionModeCloseButtonStyle">#style/ActionButton.CloseMode.Flux</item>
<!-- Light.DarkActionBar specific -->
<item name="android:actionBarWidgetTheme">#style/Theme.Flux.Widget</item>
<item name="android:actionMenuTextColor">#android:color/white</item>
<item name="actionMenuTextColor">#android:color/white</item>
</style>
<style name="ActionBar.Solid.Flux" parent="#android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">#drawable/ab_solid_flux</item>
<item name="android:backgroundStacked">#drawable/ab_stacked_solid_flux</item>
<item name="android:backgroundSplit">#drawable/ab_bottom_solid_flux</item>
<item name="android:progressBarStyle">#style/ProgressBar.Flux</item>
<item name="android:textColor">#android:color/white</item>
<item name="android:actionMenuTextColor">#android:color/white</item>
<item name="actionMenuTextColor">#android:color/white</item>
<item name="android:titleTextStyle">#style/TitleColor</item>
</style>
<style name="TitleColor" parent="android:TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#android:color/white</item>
</style>
<style name="ActionBar.Transparent.Flux" parent="#android:style/Widget.Holo.ActionBar">
<item name="android:background">#drawable/ab_transparent_flux</item>
<item name="android:progressBarStyle">#style/ProgressBar.Flux</item>
</style>
<style name="PopupMenu.Flux" parent="#android:style/Widget.Holo.ListPopupWindow">
<item name="android:popupBackground">#drawable/menu_dropdown_panel_flux</item>
</style>
<style name="DropDownListView.Flux" parent="#android:style/Widget.Holo.ListView.DropDown">
<item name="android:listSelector">#drawable/selectable_background_flux</item>
</style>
<style name="ActionBarTabStyle.Flux" parent="#android:style/Widget.Holo.ActionBar.TabView">
<item name="android:background">#drawable/tab_indicator_ab_flux</item>
</style>
<style name="DropDownNav.Flux" parent="#android:style/Widget.Holo.Spinner">
<item name="android:background">#drawable/spinner_background_ab_flux</item>
<item name="android:popupBackground">#drawable/menu_dropdown_panel_flux</item>
<item name="android:dropDownSelector">#drawable/selectable_background_flux</item>
</style>
<style name="ProgressBar.Flux" parent="#android:style/Widget.Holo.ProgressBar.Horizontal">
<item name="android:progressDrawable">#drawable/progress_horizontal_flux</item>
</style>
<style name="ActionButton.CloseMode.Flux" parent="#android:style/Widget.Holo.ActionButton.CloseMode">
<item name="android:background">#drawable/btn_cab_done_flux</item>
</style>
<!-- this style is only referenced in a Light.DarkActionBar based theme -->
<style name="Theme.Flux.Widget" parent="#android:style/Theme.Holo">
<item name="android:popupMenuStyle">#style/PopupMenu.Flux</item>
<item name="android:dropDownListViewStyle">#style/DropDownListView.Flux</item>
</style>
<style name="menu_labels_style">
<item name="android:background">#drawable/fab_label_background</item>
<item name="android:textColor">#android:color/white</item>
<item name="android:actionMenuTextColor">#android:color/white</item>
</style>
Change the style file also in values-v11 and values-v14 folders
i solve my problem when i put my style file in values-v11 and values-v14 folders i also add this style to my main style.
<item name="android:itemTextAppearance">#style/TextAppearance</item>
this is my style
<style name="Theme.Flux" parent="#android:style/Theme.Holo.Light.DarkActionBar">
<item name="android:actionBarItemBackground">#drawable/selectable_background_flux</item>
<item name="android:popupMenuStyle">#style/PopupMenu.Flux</item>
<item name="android:dropDownListViewStyle">#style/DropDownListView.Flux</item>
<item name="android:actionBarTabStyle">#style/ActionBarTabStyle.Flux</item>
<item name="android:actionDropDownStyle">#style/DropDownNav.Flux</item>
<item name="android:actionBarStyle">#style/ActionBar.Solid.Flux</item>
<item name="android:actionModeBackground">#drawable/cab_background_top_flux</item>
<item name="android:actionModeSplitBackground">#drawable/cab_background_bottom_flux</item>
<item name="android:actionModeCloseButtonStyle">#style/ActionButton.CloseMode.Flux</item>
<!-- Light.DarkActionBar specific -->
<item name="android:actionBarWidgetTheme">#style/Theme.Flux.Widget</item>
<item name="android:itemTextAppearance">#style/TextAppearance</item>
<item name="android:actionMenuTextColor">#android:color/white</item>
</style>
<style name="TextAppearance">
<item name="android:textColor">#android:color/white</item>
</style>
In my android application the text color of a sub menu item is displayed different on Android 4 (API level <=20) than Android 5.
Android 4
Android 5
My theme looks like the following:
<style name="Theme.Mytheme" parent="#android:style/Theme.Holo.Light.DarkActionBar">
<item name="android:actionBarItemBackground">#drawable/selectable_background_mytheme</item>
<item name="android:popupMenuStyle">#style/PopupMenu.Mytheme</item>
<item name="android:actionBarTabStyle">#style/ActionBarTabStyle.Mytheme</item>
<item name="android:actionDropDownStyle">#style/DropDownNav.Mytheme</item>
<item name="android:actionBarStyle">#style/ActionBar.Solid.Mytheme</item>
<item name="android:actionModeBackground">#drawable/cab_background_top_mytheme</item>
<item name="android:actionModeSplitBackground">#drawable/cab_background_bottom_mytheme</item>
<item name="android:actionModeCloseButtonStyle">#style/ActionButton.CloseMode.Mytheme</item>
<item name="android:windowBackground">#drawable/app_background</item>
<item name="android:actionMenuTextColor">#android:color/white</item>
<!-- Light.DarkActionBar specific -->
<item name="android:actionBarWidgetTheme">#style/Theme.Mytheme.Widget</item>
<!-- Widget styles -->
<item name="android:editTextBackground">#drawable/mytheme_edit_text_holo_light</item>
<item name="android:textColorHighlight">#993e74b4</item>
<item name="android:textSelectHandleLeft">#drawable/mytheme_text_select_handle_left</item>
<item name="android:textSelectHandleRight">#drawable/mytheme_text_select_handle_right</item>
<item name="android:textSelectHandle">#drawable/mytheme_text_select_handle_middle</item>
<item name="android:listChoiceIndicatorMultiple">#drawable/mytheme_btn_check_holo_light</item>
<item name="android:listChoiceIndicatorSingle">#drawable/mytheme_btn_radio_holo_light</item>
<item name="android:buttonStyle">#style/ButtonMytheme</item>
<item name="android:imageButtonStyle">#style/ImageButtonMytheme</item>
<item name="android:dropDownSpinnerStyle">#style/SpinnerMytheme</item>
<item name="android:progressBarStyleHorizontal">#style/ProgressBarMytheme</item>
<item name="android:listChoiceBackgroundIndicator">#drawable/mytheme_list_selector_holo_light</item>
<item name="android:activatedBackgroundIndicator">#drawable/mytheme_activated_background_holo_light</item>
</style>
<style name="ActionBar.Solid.Mytheme" parent="#android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">#drawable/ab_solid_mytheme</item>
<item name="android:backgroundStacked">#drawable/ab_stacked_solid_mytheme</item>
<item name="android:backgroundSplit">#drawable/ab_bottom_solid_mytheme</item>
<item name="android:progressBarStyle">#style/ProgressBar.Mytheme</item>
</style>
<style name="ActionBar.Transparent.Mytheme" parent="#android:style/Widget.Holo.ActionBar">
<item name="android:background">#drawable/ab_transparent_mytheme</item>
<item name="android:progressBarStyle">#style/ProgressBar.Mytheme</item>
</style>
<style name="PopupMenu.Mytheme" parent="#android:style/Widget.Holo.ListPopupWindow">
<item name="android:popupBackground">#drawable/menu_dropdown_panel_mytheme</item>
</style>
<style name="DropDownListView.Mytheme" parent="#android:style/Widget.Holo.ListView.DropDown">
<item name="android:listSelector">#drawable/selectable_background_mytheme</item>
<item name="android:textColor">#android:color/white</item>
</style>
<style name="ActionBarTabStyle.Mytheme" parent="#android:style/Widget.Holo.ActionBar.TabView">
<item name="android:background">#drawable/tab_indicator_ab_mytheme</item>
</style>
<style name="DropDownNav.Mytheme" parent="#android:style/Widget.Holo.Spinner">
<item name="android:background">#drawable/spinner_background_ab_mytheme</item>
<item name="android:popupBackground">#drawable/menu_dropdown_panel_mytheme</item>
<item name="android:dropDownSelector">#drawable/selectable_background_mytheme</item>
</style>
<style name="ProgressBar.Mytheme" parent="#android:style/Widget.Holo.ProgressBar.Horizontal">
<item name="android:progressDrawable">#drawable/progress_horizontal_mytheme</item>
</style>
<style name="ActionButton.CloseMode.Mytheme" parent="#android:style/Widget.Holo.ActionButton.CloseMode">
<item name="android:background">#drawable/btn_cab_done_mytheme</item>
</style>
<!-- this style is only referenced in a Light.DarkActionBar based theme -->
<style name="Theme.Mytheme.Widget" parent="#android:style/Theme.Holo">
<item name="android:popupMenuStyle">#style/PopupMenu.Mytheme</item>
<item name="android:dropDownListViewStyle">#style/DropDownListView.Mytheme</item>
</style>
What has changed from Android 4 to Android 5 ? What should I add on my theme/style so that I can achieve the same text color on both versions ?
I want to change the background color of the backbutton and overflowmenu button on pressed state.
I am using ActionBarActivity . Appcompact v7 library.
Programmatically is it possible to change background color of the back button and overflowmenubutton ?
Below is my styles:
<resources>
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
<!-- <item name="windowActionBar">false</item> -->
</style>
<style name="ActionBar.Solid.Sri" parent="#style/Widget.AppCompat.Light.ActionBar.Solid">
<item name="background">#drawable/ab_solid_sri</item>
<item name="backgroundStacked">#drawable/ab_stacked_solid_sri</item>
<item name="backgroundSplit">#drawable/ab_bottom_solid_sri</item>
<item name="progressBarStyle">#style/ProgressBar</item>
</style>
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:actionBarDivider">#color/action_bar_text_color</item>
<item name="actionBarDivider">#color/action_bar_text_color</item>
<item name="actionBarItemBackground">#drawable/selectable_background_sri</item>
<item name="android:actionBarStyle">#style/ActionBar.Transparent</item>
<item name="actionBarStyle">#style/ActionBar.Transparent</item>
<!--
<item name="android:actionBarStyle">#style/MyActionBar</item>
<item name="actionBarStyle">#style/MyActionBar</item>
-->
<item name="actionOverflowMenuStyle">#style/OverflowMenu</item>
<item name="popupMenuStyle">#style/PopupMenu</item>
<item name="dropDownListViewStyle">#style/DropDownListView</item>
<item name="android:popupMenuStyle">#style/PopupMenu</item>
<item name="android:dropDownListViewStyle">#style/DropDownListView</item>
<item name="actionModeBackground">#drawable/cab_background_top_sri</item>
<item name="actionModeSplitBackground">#drawable/cab_background_bottom_sri</item>
<item name="actionModeCloseButtonStyle">#style/ActionButton.CloseMode</item>
<!--
<item name="actionOverflowButtonStyle">#style/OverFlowStyle</item>
<item name="android:actionOverflowButtonStyle">#style/OverFlowStyle</item>
-->
<item name="actionDropDownStyle">#style/DropDownNav</item>
<item name="android:actionDropDownStyle">#style/DropDownNav</item>
<item name="android:actionBarTabTextStyle">#style/TabTextStyle</item>
<item name="actionBarTabTextStyle">#style/TabTextStyle</item>
<item name="actionBarTabStyle">#style/ActionBarTabStyle</item>
<item name="android:actionBarTabStyle">#style/ActionBarTabStyle</item>
<!-- <item name="actionBarStyle">#style/Theme.MyApp.ActionBar</item> -->
</style>
<style name="ActionButton.CloseMode" parent="#style/Widget.AppCompat.Light.ActionButton.CloseMode">
<item name="android:background">#drawable/btn_cab_done_sri</item>
</style>
<style name="DropDownListView" parent="#style/Widget.AppCompat.Light.ListView.DropDown">
<item name="android:listSelector">#drawable/selectable_background_sri</item>
</style>
<style name="PopupMenu" parent="#style/Widget.AppCompat.Light.PopupMenu">
<item name="android:popupBackground">#drawable/menu_dropdown_panel_sri</item>
</style>
<style name="MyActionBar" parent="#style/Widget.AppCompat.ActionBar">
<item name="android:titleTextStyle">#style/TitleTextStyle</item>
<!-- Support library compatibility -->
<item name="titleTextStyle">#style/TitleTextStyle</item>
</style>
<style name="ActionBar.Transparent" parent="#style/Widget.AppCompat.Light.ActionBar">
<item name="background">#drawable/ab_transparent_sri</item>
<item name="progressBarStyle">#style/ProgressBar</item>
<item name="android:titleTextStyle">#style/TitleTextStyle</item>
<!-- Support library compatibility -->
<item name="titleTextStyle">#style/TitleTextStyle</item>
</style>
<style name="ProgressBar" parent="#style/Widget.AppCompat.ProgressBar.Horizontal">
<item name="android:progressDrawable">#drawable/progress_horizontal_sri</item>
</style>
<style name="OverFlowStyle" parent="#style/Widget.AppCompat.Light.ActionButton.Overflow">
<item name="android:src">#drawable/ic_empty</item>
</style>
<style name="TitleTextStyle" parent="#style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">#color/action_bar_text_color</item>
</style>
<style name="TabTextStyle" parent="#style/Widget.AppCompat.ActionBar.TabText">
<item name="android:textColor">#color/action_bar_text_color</item>
</style>
<style name="ActionBarTabStyle" parent="#style/Widget.AppCompat.Light.ActionBar.TabView">
<item name="android:background">#drawable/tab_indicator_ab_sri</item>
<item name="background">#drawable/tab_indicator_ab_sri</item>
</style>
<style name="DropDownNav" parent="#style/Widget.AppCompat.Light.Spinner.DropDown.ActionBar">
<item name="android:background">#drawable/spinner_background_ab_sri</item>
<item name="android:popupBackground">#drawable/menu_dropdown_panel_sri</item>
<item name="android:dropDownSelector">#drawable/selectable_background_sri</item>
<item name="background">#drawable/spinner_background_ab_sri</item>
</style>
<!--
<style name="Theme.MyApp.ActionBar" parent="style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
remove shadow below action bar
<item name="android:elevation">0dp</item>
Support library compatibility
<item name="elevation">0dp</item>
<item name="android:windowContentOverlay">#null</item>
</style>
-->
<style name="OverflowMenu" parent="Widget.AppCompat.PopupMenu.Overflow">
<!-- Required for pre-Lollipop. -->
<item name="overlapAnchor">false</item>
<!-- Required for Lollipop. -->
<!-- <item name="android:overlapAnchor">false</item> -->
</style>
<style name="ProgressBarStyle" parent="#android:style/Widget.ProgressBar.Horizontal" />
<!--
<style name="MyActionBar" parent="#style/Widget.AppCompat.ActionBar">
<item name="android:background">#drawable/actionbar_background</item>
<item name="android:windowActionBarOverlay">true</item>
Support library compatibility
<item name="background">#drawable/actionbar_background</item>
<item name="windowActionBarOverlay">true</item>
</style>
-->
<!-- this style is only referenced in a Light.DarkActionBar based theme -->
<style name="Theme.Sri.Widget" parent="#style/Theme.AppCompat">
<item name="popupMenuStyle">#style/PopupMenu</item>
<item name="dropDownListViewStyle">#style/DropDownListView</item>
</style>
</resources>
Please help me. Thank you guys.
The Action Bar Style Generator is very useful, but it generates a lot of files, most of which are irrelevant if you only want to change the background colour please look at this:
https://stackoverflow.com/a/20077381/611258.
Although i strongly urge you to use the new toolbar or its support library equivalent.
I'm using ActionBarSherlock and HoloEverywhere in my app. I used the ActionBar Style Generator to generate my styles and then modified them a bit by hand for text colors, etc.
I'm having a problem where my ActionBar looks correct on my Android 4.2 device (that is, orange with white text), but on my Android 2.3 device the ActionBar is black with grey text.
Does anyone know what might cause this?
<style name="Theme.MyApp" parent="#style/Holo.Theme.Light.DarkActionBar">
<item name="android:actionBarItemBackground">#drawable/selectable_background_MyApp</item>
<item name="android:popupMenuStyle">#style/PopupMenu.MyApp</item>
<item name="android:dropDownListViewStyle">#style/DropDownListView.MyApp</item>
<item name="android:actionBarTabStyle">#style/ActionBarTabStyle.MyApp</item>
<item name="android:actionDropDownStyle">#style/DropDownNav.MyApp</item>
<item name="android:actionBarStyle">#style/ActionBar.Solid.MyApp</item>
<item name="android:actionModeBackground">#drawable/cab_background_top_MyApp</item>
<item name="android:actionModeSplitBackground">#drawable/cab_background_bottom_MyApp</item>
<item name="android:actionModeCloseButtonStyle">#style/ActionButton.CloseMode.MyApp</item>
<!-- <item name="android:textColorPrimary">#FFFFFF</item> -->
<item name="android:spinnerDropDownItemStyle">#style/ActionBar.Solid.MyApp.NavigationDropDownStyle</item>
</style>
<style name="ActionBar.Solid.MyApp" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#drawable/ab_solid_MyApp</item>
<item name="android:backgroundStacked">#drawable/ab_stacked_solid_MyApp</item>
<item name="android:backgroundSplit">#drawable/ab_bottom_solid_MyApp</item>
<item name="android:progressBarStyle">#style/ProgressBar.MyApp</item>
<item name="android:titleTextStyle">#style/ActionBar.Solid.MyApp.TitleTextStyle</item>
</style>
<style name="ActionBar.Solid.MyApp.NavigationDropDownStyle" parent="#android:style/Widget.Holo.DropDownItem.Spinner">
<item name="android:textAppearance">#style/ActionBar.Solid.MyApp.NavigationDropDownStyle.TextStyle</item>
</style>
<style name="ActionBar.Solid.MyApp.NavigationDropDownStyle.TextStyle" parent="#android:style/Widget">
<item name="android:textColor">#color/white</item>
<item name="android:textSize">18sp</item>
</style>
<style name="ActionBar.Solid.MyApp.TitleTextStyle" parent="#android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#color/white</item>
<item name="android:textSize">18sp</item>
<!-- <item name="android:fontFamily">sans-serif-medium</item> -->
</style>
<style name="ActionBar.Transparent.MyApp" parent="#android:style/Widget.Holo.ActionBar">
<item name="android:background">#drawable/ab_transparent_MyApp</item>
<item name="android:progressBarStyle">#style/ProgressBar.MyApp</item>
</style>
<style name="PopupMenu.MyApp" parent="#android:style/Widget.Holo.ListPopupWindow">
<item name="android:popupBackground">#drawable/menu_dropdown_panel_MyApp</item>
</style>
<style name="DropDownListView.MyApp" parent="#android:style/Widget.Holo.ListView.DropDown">
<item name="android:listSelector">#drawable/selectable_background_MyApp</item>
</style>
<style name="ActionBarTabStyle.MyApp" parent="#android:style/Widget.Holo.ActionBar.TabView">
<item name="android:background">#drawable/tab_indicator_ab_MyApp</item>
</style>
<style name="DropDownNav.MyApp" parent="#android:style/Widget.Holo.Spinner">
<item name="android:background">#drawable/spinner_background_ab_MyApp</item>
<item name="android:popupBackground">#drawable/menu_dropdown_panel_MyApp</item>
<item name="android:dropDownSelector">#drawable/selectable_background_MyApp</item>
</style>
<style name="ProgressBar.MyApp" parent="#android:style/Widget.Holo.ProgressBar.Horizontal">
<item name="android:progressDrawable">#drawable/progress_horizontal_MyApp</item>
</style>
<style name="ActionButton.CloseMode.MyApp" parent="#android:style/Widget.Holo.ActionButton.CloseMode">
<item name="android:background">#drawable/btn_cab_done_MyApp</item>
</style>
<!-- this style is only referenced in a Light.DarkActionBar based theme -->
<style name="Theme.MyApp.Widget" parent="#android:style/Theme.Holo">
<item name="android:popupMenuStyle">#style/PopupMenu.MyApp</item>
<item name="android:dropDownListViewStyle">#style/DropDownListView.MyApp</item>
</style>
--------------- EDIT ----------------------
So I'm now having a problem where the action bar is taking up the entire screen on the Android 2.3 device (but works fine on Android 4.2). Do I need to remove the "android:" from the parent attributes?
parent="#android:style/Widget.Holo.ListPopupWindow"
When I tried this, Eclipse was unable to find the theme.
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="Theme.MyApp" parent="#style/Holo.Theme.Light.DarkActionBar">
<item name="android:actionBarItemBackground">#drawable/selectable_background_MyApp</item>
<item name="android:popupMenuStyle">#style/PopupMenu.MyApp</item>
<item name="android:dropDownListViewStyle">#style/DropDownListView.MyApp</item>
<item name="android:actionBarTabStyle">#style/ActionBarTabStyle.MyApp</item>
<item name="android:actionDropDownStyle">#style/DropDownNav.MyApp</item>
<item name="android:actionBarStyle">#style/ActionBar.Solid.MyApp</item>
<item name="android:actionModeBackground">#drawable/cab_background_top_MyApp</item>
<item name="android:actionModeSplitBackground">#drawable/cab_background_bottom_MyApp</item>
<item name="android:actionModeCloseButtonStyle">#style/ActionButton.CloseMode.MyApp</item>
<!-- <item name="android:textColorPrimary">#FFFFFF</item> -->
<item name="android:spinnerDropDownItemStyle">#style/ActionBar.Solid.MyApp.NavigationDropDownStyle</item>
<item name="actionBarItemBackground">#drawable/selectable_background_MyApp</item>
<item name="popupMenuStyle">#style/PopupMenu.MyApp</item>
<item name="dropDownListViewStyle">#style/DropDownListView.MyApp</item>
<item name="actionBarTabStyle">#style/ActionBarTabStyle.MyApp</item>
<item name="actionDropDownStyle">#style/DropDownNav.MyApp</item>
<item name="actionBarStyle">#style/ActionBar.Solid.MyApp</item>
<item name="actionModeBackground">#drawable/cab_background_top_MyApp</item>
<item name="actionModeSplitBackground">#drawable/cab_background_bottom_MyApp</item>
<item name="actionModeCloseButtonStyle">#style/ActionButton.CloseMode.MyApp</item>
<!-- <item name="textColorPrimary">#FFFFFF</item> -->
<item name="spinnerDropDownItemStyle">#style/ActionBar.Solid.MyApp.NavigationDropDownStyle</item>
</style>
<style name="ActionBar.Solid.MyApp" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#drawable/ab_solid_MyApp</item>
<item name="android:backgroundStacked">#drawable/ab_stacked_solid_MyApp</item>
<item name="android:backgroundSplit">#drawable/ab_bottom_solid_MyApp</item>
<item name="android:progressBarStyle">#style/ProgressBar.MyApp</item>
<item name="android:titleTextStyle">#style/ActionBar.Solid.MyApp.TitleTextStyle</item>
<item name="background">#drawable/ab_solid_MyApp</item>
<item name="backgroundStacked">#drawable/ab_stacked_solid_MyApp</item>
<item name="backgroundSplit">#drawable/ab_bottom_solid_MyApp</item>
<item name="progressBarStyle">#style/ProgressBar.MyApp</item>
<item name="titleTextStyle">#style/ActionBar.Solid.MyApp.TitleTextStyle</item>
</style>
<style name="ActionBar.Solid.MyApp.NavigationDropDownStyle" parent="#android:style/Widget.Holo.DropDownItem.Spinner">
<item name="android:textAppearance">#style/ActionBar.Solid.MyApp.NavigationDropDownStyle.TextStyle</item>
</style>
<style name="ActionBar.Solid.MyApp.NavigationDropDownStyle.TextStyle" parent="#android:style/Widget">
<item name="android:textColor">#color/white</item>
<item name="android:textSize">18sp</item>
</style>
<style name="ActionBar.Solid.MyApp.TitleTextStyle" parent="#android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#color/white</item>
<item name="android:textSize">18sp</item>
<!-- <item name="android:fontFamily">sans-serif-medium</item> -->
</style>
<style name="ActionBar.Transparent.MyApp" parent="#android:style/Widget.Holo.ActionBar">
<item name="android:background">#drawable/ab_transparent_MyApp</item>
<item name="android:progressBarStyle">#style/ProgressBar.MyApp</item>
<item name="background">#drawable/ab_transparent_MyApp</item>
<item name="progressBarStyle">#style/ProgressBar.MyApp</item>
</style>
<style name="PopupMenu.MyApp" parent="#android:style/Widget.Holo.ListPopupWindow">
<item name="android:popupBackground">#drawable/menu_dropdown_panel_MyApp</item>
</style>
<style name="DropDownListView.MyApp" parent="#android:style/Widget.Holo.ListView.DropDown">
<item name="android:listSelector">#drawable/selectable_background_MyApp</item>
</style>
<style name="ActionBarTabStyle.MyApp" parent="#android:style/Widget.Holo.ActionBar.TabView">
<item name="android:background">#drawable/tab_indicator_ab_MyApp</item>
<item name="background">#drawable/tab_indicator_ab_MyApp</item>
</style>
<style name="DropDownNav.MyApp" parent="#android:style/Widget.Holo.Spinner">
<item name="android:background">#drawable/spinner_background_ab_MyApp</item>
<item name="android:popupBackground">#drawable/menu_dropdown_panel_MyApp</item>
<item name="android:dropDownSelector">#drawable/selectable_background_MyApp</item>
<item name="background">#drawable/spinner_background_ab_MyApp</item>
</style>
<style name="ProgressBar.MyApp" parent="#android:style/Widget.Holo.ProgressBar.Horizontal">
<item name="android:progressDrawable">#drawable/progress_horizontal_MyApp</item>
</style>
<style name="ActionButton.CloseMode.MyApp" parent="#android:style/Widget.Holo.ActionButton.CloseMode">
<item name="android:background">#drawable/btn_cab_done_MyApp</item>
<item name="background">#drawable/btn_cab_done_MyApp</item>
</style>
</resources>
As per the official docs, you need to also declare the attributes without the android: namespace. In your case, those attributes are only getting applied to the native implementation.