I'm using Actionbar in my app and I want to change its style. Specifically I want to change the color of the ripple when touching the different components of the actionbar.
What I want is to style the action bar to have :
Texts with light colors.
Light Highlight colors for actionbar icons (white circle ripple).
Dark Highlight colors for the dropDown window of the searchView.
What I achieved so far :
I've set the colors of the text to Light colors.
I've changed the Highlight color of the actionbar icons to Light color.
But this Light Highlight color is also propagated to the dropdown window, which I don't want...
Here's the style I created for my actionbar :
<style name="AppTheme.Base.Theme4.ActionBar.Theme" parent="#style/ThemeOverlay.AppCompat.ActionBar">
<item name="android:windowBackground">#color/background_material_light</item>
<item name="colorControlHighlight">#color/ripple_material_dark</item>
<item name="android:textColorPrimary">#color/abc_primary_text_material_dark</item>
<item name="android:textColorPrimaryDisableOnly">#color/abc_primary_text_disable_only_material_dark</item>
<item name="android:textColorHint">#color/hint_foreground_material_dark</item>
<item name="colorControlNormal">#fff</item>
</style>
Is there any way to put different Highlight colors for the icons and the dropdown window ?
try to use the sherlock action bar library it will convenient to modify action bar as you want. you can download this library from given link-
http://actionbarsherlock.com/download.html
Related
I use android.support.v7.widget.Toolbar in my project. By default in light theme it has black action overflow menu icon, black title and black overflow menu text color, like that (don't look at the navigation icon - it's custom):
But in my App I need it to be white.
I set android:textColorPrimary to white in my styles for the toolbar:
<style name="Widget.My.Toolbar" parent="Widget.AppCompat.Toolbar">
<item name="theme">#style/ThemeOverlay.My.Toolbar</item>
</style>
<style name="ThemeOverlay.My.Toolbar" parent="ThemeOverlay.AppCompat.ActionBar">
<item name="android:textColorPrimary">#color/white</item>
</style>
It changed color of the title and the overflow menu button just like I wanted, but it changed Action owerflow menu items text color too:
It looks ugly.
I even tried set a Title color programmatically with
toolbar.setTitleTextColor(getResources.getColor(R.color.white);
but it changes ONLY Title color, and not changes menu button:
So how can I change color for everything in the toolbar, except items in action overflow menu?
After you set the text color for for your Toolbar you can set the text color of your menus with the following attribute:
<item name="actionMenuTextColor">#color/white</item>
Since you are using the AppCompat Toolbar the android namespace need not be included in the attribute, as shown above.
However, it seems people have had mixed experience with this. You can also try using the itemTextAppearance attribute:
<style name="yourTheme" parent="yourThemeParent">
<!-- Rest of your theme -->
<item name="android:itemTextAppearance">#style/menuItemColor</item>
</style>
<style name="menuItemColor">
<item name="android:textColor">#android:color/black</item>
</style>
I found that the first solution worked for me when I explicitly included a Toolbar in my layout, but not if I used getSupportActionBar() to get the default bar included in a given theme. However, in this scenario, the second solution did work for me.
So my app theme extends from AppCompat's Material Light theme with Dark Action Bar.
I applied an accent color.
Now I am trying to use a Spinner on a dark backround and because of the theme, the spinner has a dark gray arrow which changes to accent color when pressed.
How can I make this spinner's arrow white so that it is prominent on a dark background?
Here's the image of the Spinner:
If you want to apply same spinner style app wide, then in your values/styles.xml, override spinnerStyle with your custom style, which derives from an appcompat type and override android:background:
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="android:spinnerStyle">#style/AppSpinner</item>
</style>
<style name="AppSpinner" parent="Widget.AppCompat.Spinner">
<item name="android:background">#drawable/your_spinner_background</item>
</style>
If you need a quick way to generate a spinner background, try android-holo-colors, choose Colored Spinner and supply your accent color.
So the support library 22.1 enables use of android:theme attribute on views. That should help here.
with android:background you can specify your own background resource. I find the arrow rather useless (tapping the spinner brings dropdown menu even without arrow) so if you don't want to draw a custom arrow image, just leave the background black or transparent.
Just tried ShareActinProvider from AppCompat v7 and while the drop down from the action bar menu is light and good, the drop down from the ShareActionProvider share button is dark.
This is the style applied.
<style name="Theme.Pinnr" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#C62828</item>
<item name="colorPrimaryDark">#B71C1C</item>
</style>
I want both menus to have the same color.
Here is the bad menu image:
Here is the good menu image:
Update
I am in fact aware that I can change the color of that popup background with this code
<style name="Theme.Pinnr.listPopupWindowStyle" parent="Widget.AppCompat.Spinner.DropDown.ActionBar">
<item name="android:popupBackground">#eeeeee</item>
</style>
My question is why its happening and shouldn't just behave like the other menu. And hopefully how do I set it to match the other menu without hardcoding the color for the popup
Had the same issue and it was because I was based on Ligh.DarkActionBar theme. Changed to just the Light theme and it worked fine.
I'm using last release of support library (V21) which include material themes (under Theme.AppCompat name) and I want to put ActionBar title in white. I tried to achieve it by using textColorPrimary (as it's shown there) attribut in my custom theme
<style name="AppBaseTheme" parent="#style/Theme.AppCompat.Light">
<item name="colorPrimary">#color/orange</item>
<item name="colorPrimaryDark">#color/orange_dark</item>
<item name="colorAccent">#color/white</item>
<!-- This attribut set text color -->
<item name="android:textColorPrimary">#color/white</item>
</style>
With this I got a white actionbar title but all other text (textview, edittext) were white too...
Is there a way to change only actionbar title color with recently released features or the only way is to use a custom style for action bar, just like it was the case with Holo ?
Use #style/Theme.AppCompat.Light.DarkActionBar to invert the text color only in the Action Bar.
In my TextView I enabled text-selection with android:textIsSelectable.
The problem is, that the appearing actionbar is white and the color of the buttons (copy , select, etc.) is white too. (I use actionbarsherlock 4.4.0)
Is there a possibility to change the color of these items in the styles.xml and if yes: What is the correct way?
Edit:
I found out that i can customize the ActionMode Tab using:
<style name="MyCustomTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:actionModeBackground">#color/color1</item>
<item name="android:actionModeSplitBackground">#color/color1</item>
</style>
But i am not able to change the color of the buttons