I am trying to change the blue background of a focussed/pressed menuitem in the overflow menu.
I'm talking about this:
I think I've overwritten every possible attribute from the Themeand Theme.Holo in Themes.xml and went to each style in Styles.xml but couldn't change the blue background.
EDIT
i figured out that the style i should override is android:dropDownListViewStyle
but it didn't work at all.
but then i changed the theme from Theme.Holo.Light.DarkActionBar to Theme.Holo.Light and guess what? it worked!!
so, can anyone shed some light on this?? how can i change the color on a theme with DarkActionBar??
ok, i found a solution for my problem: link to a post in the ActionBarSherlock google group
i've overseen this entry: android:actionBarWidgetTheme in the Theme.Holo.Light.DarkActionBar theme.
now all i had to do is define a theme that overrides Theme.Holo with one style in it: <item name="android:dropDownListViewStyle">#style/myDropDownListView</item> and point to this theme instead.
<!-- theme referenced by actionBarWidgetTehme style -->
<style name="Theme.DropDown.Dark" parent="android:style/Theme.Holo">
<item name="android:dropDownListViewStyle">#style/myDropDownListView</item>
</style>
<!-- my main theme -->
<style name="DarkActionBarRedActionMode" parent="android:style/Theme.Holo.Light.DarkActionBar">
<item name="android:actionBarWidgetTheme">#style/Theme.DropDown.Dark</item>
</style>
declare a selector drawable, and put it as background of listview item.
refer to drawable resource
Related
I have a project where I defined all the styles in the theme (Button style, Checkbox Style, EditText style and so on) This way I don't need to apply any style or theme in the layouts where I use those views, because they are applied automatically by my AppTheme.
Now I encountered a problem. I wanted to define the Switch style inside the theme but it should use another color for the colorControlActivated and colorControlHighlight. By default it uses the colorPrimary which I defined in the theme, but what if I want to change that.
The problem can be fixed easy with a theme overlay or a style where I override the needed attributes that I mentioned above and apply that style/theme everywhere where I use the Swtch view. But I want to know if I can avoid that and define a default style for my Switch views inside the same theme where the colorControlActivated and colorControlHighlight are already defined.
I tried several things but this looked like the one that actually might work but it does not:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorControlActivated">#color/colorPrimary</item>
<item name="colorControlHighlight">#color/colorPrimary</item>
<item name="colorSwitchThumbNormal">#color/white</item>
<item name="switchStyle">#style/SwitchStyle</item>
</style>
<style name="AppTheme.GreenControlOverlay">
<item name="colorControlActivated">#color/green</item>
<item name="colorControlHighlight">#color/green</item>
</style>
the SwitchStyle looks like this
<style name="SwitchStyle" parent="Widget.AppCompat.CompoundButton.Switch">
<item name="android:theme">#style/AppTheme.GreenControlOverlay</item>
</style>
I dont know why this is not working because if I set the android:theme inside my AppTheme directly it does override the colorControl attributes, but if you override it from a style it does not work. If I apply this GreenControlOverlay on the Switch view inside of my layout it also works.
Is it even possible to do this?
If you have any questions please don't hesitate to ask. I hope I explained my problem well.
Can't find how to set background color of ActionBar in collapsed state.
In fullscreen/opened state it works well but in collapsed/minimized it always the same gray color (color of android theme i derive from).
I want it to look like in youtube app.
Please help me.
Thank you beforehand.
Solution found.
Just set color to android:colorPrimary property.
<style name="AppTheme" parent="#style/Theme.AppCompat.Light">
<item name="android:textColorPrimary" tools:targetApi="21">#color/white</item>
<item name="android:colorPrimary" tools:targetApi="21">#color/green_back</item>
<item name="android:colorPrimaryDark" tools:targetApi="21">#color/green_back_dark</item>
...
</style>
I'm trying to implement a feature to let the user change the theme.
I've done this but depending on if the theme is light or dark, I need to use the opposite color to draw line on a canvas. I thought the best way to do this would be to simply call R.style.colorAttribute to get the correct color when doing the drawing.
In the styles.xml I have defined the following themes:
<style name="DarkTheme" parent="android:Theme.Holo" />
<style name="LightTheme" parent="android:Theme.Holo.Light" />
Can anyone help on the best way to add an attribute here which will store the color. I've not done this before and was n't sure if I should use the color.xml file or the styles.xml file.
Thanks
And just to make it clear
I for the dark theme I need a white color
and for the light them I need the same attribute but in black.
If you like a theme, but want to tweak it, just add the theme as the parent of your custom theme. For example, you can modify the traditional light theme to use your own color like this:
<color name="custom_theme_color">#b0b0ff</color>
<style name="CustomTheme" parent="android:Theme.Light">
<item name="android:windowBackground">#color/custom_theme_color</item>
<item name="android:colorBackground">#color/custom_theme_color</item>
</style>
More about styles on developer.android.com.
I am the using the ActionBarSherlock. I have the displayOption "homeAsUp" in my style.xml file. Now this shows a black arrow next to the title of the Activity. Since my theme is White on a blue blackground, i want to change the color of the black arrow, or maybe use a whole new icon resource in its place. How can i do this ?
Kind Regards.
Further to Eric's answer - I wasted a lot of time getting this right.
Remember that these items must go in the parent application theme, inheriting from Theme.Sherlock or similar.
<!-- CUSTOM APP THEME -->
<style name="AppTheme" parent="Theme.Sherlock">
<item name="android:actionBarStyle">#style/AppTheme.ActionBarStyle</item>
<item name="actionBarStyle">#style/AppTheme.ActionBarStyle</item>
<item name="android:homeAsUpIndicator">#drawable/action_bar_ic_ab_back_holo_dark</item>
<item name="homeAsUpIndicator">#drawable/action_bar_ic_ab_back_holo_dark</item>
</style>
Do not put them in the custom Action Bar theme inheriting from Widget.Sherlock.ActionBar.
<!-- ACTION BAR THEME -->
<style name="AppTheme.ActionBarStyle" parent="Widget.Sherlock.ActionBar">
<item name="android:icon">#drawable/action_bar_logo</item>
<item name="icon">#drawable/action_bar_logo</item>
<item name="android:displayOptions">showHome</item>
<item name="displayOptions">showHome</item>
</style>
Be careful when you style ActionBarSherlock !
Here is an extract from the web site (ActionBarSherlock Theming):
Due to limitations in Android's theming system any theme customizations must be declared in two attributes. The normal android-prefixed attributes apply the theme to the native action bar and the unprefixed attributes are for the custom implementation. Since both theming APIs are exactly the same you need only reference your customizations twice rather than having to implement them twice.
So in your case you MUST define two item:
<item name="android:homeAsUpIndicator">#drawable/icon</item>
and
<item name="homeAsUpIndicator">#drawable/icon</item>
Then you are sure that ALL your users will have the same L&F
I've got a custom theme that inherits from Theme.Holo.Light.DarkActionBar and I'm trying to change the theme's tabWidget style so it to look like if the theme was Theme.Holo Dark.
I've tried this in my theme with no result
<style name="AppTheme" parent="android:style/Theme.Holo.Light.DarkActionBar">
<item name="android:tabWidgetStyle">#android:style/Widget.Holo.TabWidget</item>
...
</style>
The only thing I can appreciate is there is a small change in the blue bar of the tab.
Any idea how to get it? Thanks!
Try also the items "android:tabStripLeft" and "android:tabStripRight".