Contextual Actionbar styles
I posted a comment to my own question, and this is actually a bug in the version of android I was using (Probably an early version of 4.0)
This is the bug described: http://code.google.com/p/android/issues/detail?id=26008
Styling the contextual action bar?
Try adding this to your style in your styles.xml and use any custom color you would like.
<item name="android:actionModeBackground">@android:color/holo_orange_light</item>
You can also change the drawables for each icon using similar code.
android:actionModeCloseDrawable
android:actionModeCopyDrawable
android:actionModeCutDrawable
android:actionModePasteDrawable
android:actionModeSelectAllDrawable
Credit to the tutorial here - http://www.codercowboy.com/2013/07/05/styling-the-contextual-action-bar-actionmode-divider-or-splitter-for-android/
for changing the contextual action bar icons. Which told me that starting with actionMode changes the contextual action bar attributes
Why is Contextual Action Bar getting different style when calling startSupportActionMode inside onCreate method?
Adding the following lines to values/styles.xml
/ BaseTheme
solved the problem:
<item name="actionBarPopupTheme">@style/ThemeOverlay.AppCompat.Light</item>
<item name="actionBarTheme">@style/ThemeOverlay.AppCompat.Dark.ActionBar</item>
Although I could not figure out what exactly was happening since this themes were already defined on my Toolbar
widget and the setSupportActionBar
was called before startSupportActionMode
.
Maybe the context action bar was being created before the styles from Toolbar
widget could be parsed by the setSupportActionBar
.
how to Customize the Contextual Action Bar using appCompat in material design
You can change the ActionMode
background through attribute actionModeStyle
:
<style name="AppTheme.Base" parent="Theme.AppCompat.Light">
....
....
<item name="actionModeStyle">@style/LStyled.ActionMode</item>
</style>
<style name="LStyled.ActionMode" parent="@style/Widget.AppCompat.ActionMode">
<item name="background">@color/color_action_mode_bg</item>
</style>
You will of course need to define a color named color_action_mode_bg
:
<color name="color_action_mode_bg">#009688</color>
There are other things you can change as well. Example:
<item name="titleTextStyle">...</item>
<item name="subtitleTextStyle">...</item>
<item name="height">...</item>
To change text color of SAVE
and SAVETO
, add the following to AppTheme.Base
:
<item name="actionMenuTextColor">@color/color_action_mode_text</item>
Change the color of Contextual Action Bar
You need to add following in your theme defined under styles.xml
,
<item name="android:actionBarStyle">@style/Widget.Styled.ActionBar</item>
<item name="android:actionModeBackground">@drawable/actionmode_background</item>`
Change Contextual Action Bar Overflow Style
Use following item
<item name="actionOverflowMenuStyle">@style/LStyled.PopupMenu.OverflowMenu</item>
And define the style LStyled.PopupMenu.OverflowMenu
<style name="LStyled.PopupMenu.OverflowMenu" parent="@style/Widget.AppCompat.PopupMenu.Overflow">
<item name="android:popupBackground">@drawable/bground</item>
</style>
Related Topics
How to Compile C into an Executable Binary File and Run It in Android from Android Shell
How to Request Root Access in Android
Dynamically Updating an Autocompletetextview Adapter
Dynamically Add Textviews to a Linearlayout
Phonegap Plugin:How to Convert Base64 String to a Png Image in Android
Why Ondraw Is Not Called After Invalidate()
Admob Shows Test Ads But Not Real Ads
Disable or Prevent Multitouch in Activity
How to Close All the Activities of My Application
Unregistered_On_Api_Console While Getting Oauth2 Token on Android
Android: How to Convert Whole Imageview to Bitmap
How to Implement Export SQLite to Excel/CSV File in Android
How to Compile a Static Library Using the Android Ndk
Create Custom Big Notifications
Android: When Is Oncreateoptionsmenu Called During Activity Lifecycle