White title background in ActionBar after changing the Actionbar Colour - android

I followed the steps mentioned in Styling the Action Bar | Android Developers to change the colour of the action bar.
But I am getting weird action bar. The actionbar colour is changed to green but the text in actionbar has different background (white), the buttons in actionbar has different background (white).
The code I used is as follows:
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<item name="android:background">#color/core_white</item>
<item name="android:actionBarStyle">#style/ActionBar</item>
<item name="android:buttonStyle">#style/Button</item>
<item name="android:editTextStyle">#style/EditText</item>
</style>
<style name="ActionBar" parent="#android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">#color/core_other</item>
<item name="android:backgroundStacked">#color/core_other_light</item>
<item name="android:backgroundSplit">#color/core_other</item>
</style>
Below are the screen shots of the theme I got:

<style name="AppTheme" parent="android:Theme.Material.Light.DarkActionBar">
<item name="android:actionBarStyle">#style/ActionBar</item>
<item name="android:buttonStyle">#style/Button</item>
<item name="android:editTextStyle">#style/EditText</item>
<item name="android:windowBackground">#android:color/black</item>
</style>
<style name="ActionBar" parent="#android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:backgroundStacked">#color/core_other_light</item>
<item name="android:backgroundSplit">#color/core_other</item>
<item name="android:background">#00ff00</item>
</style
>
Change background in app theme to windowBackground
More detail check :
https://developer.android.com/training/material/theme.html
I have used Material Theme you can use holo or other

try this
<resources>
<style name="AppTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/ActionBar</item>
</style>
<style name="ActionBar" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">ANY_HEX_COLOR_CODE</item>
</style>
</resources>

Related

What is wrong with my Android style attributes, actionbar title hidden or no color?

I'm trying to customize ActionBar using styles.xml on KITKAT and older versions.
This is as far I got it, but missing actionbar title, no color inserted properly, height or what is wrong?
Here is my styles.xml
<style name="Theme.MyApp" parent="AppTheme">
<item name="actionBarStyle">#style/Theme.MyApp.ActionBar</item>
<item name="android:actionBarStyle">#style/Theme.MyApp.ActionBar</item>
</style>
<style name="Theme.MyApp.ActionBar" parent="style/Theme.MyApp">
<item name="elevation">4dp</item>
<item name="android:height">56dp</item>
<item name="android:textColor">#color/white</item>
<item name="android:icon">#drawable/icon_placeholder_compat</item>
<item name="android:background">#color/blue</item>
<item name="android:titleTextStyle">#style/Theme.MyApp.ActionBar.TitleTextStyle</item>
<item name="titleTextStyle">#style/Theme.MyApp.ActionBar.TitleTextStyle</item>
</style>
<style name="Theme.MyApp.ActionBar.TitleTextStyle" parent="style/Theme.MyApp.ActionBar">
<item name="android:textColor">#color/white</item>
<item name="android:color">#color/white</item>
</style>
For change color of action bar and status bar:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/action_bar_color</item>
<item name="colorPrimaryDark">#color/status_bar_color</item>
</style>

Android ActionBar Background gets overridden by AppTheme Background

I just can't figure this one out:
I have an application with an ActionBar, I want the ActionBar to be red and the background of the app blue. I tried to achieve this with this styles.xml:
<style name="AppTheme" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:background">#color/blue</item>
<item name="background">#color/blue</item>
<item name="android:layout_marginTop">5dp</item>
<item name="android:actionBarStyle">#style/MyActionBar</item>
<item name="actionBarStyle">#style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background">#color/red</item>
<item name="background">#color/red</item>
</style>
But the actionBar is always blue. When I take away the blue background of the app, the actionBar is red as desired...
Any ideas?
The margin that you set is ambiguous and does not apply to anything. You should set the margin on your action bar theme:
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#color/red</item>
<item name="android:windowBackground">#color/blue</item>
<item name="actionBarStyle">#style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:layout_marginTop">5dp</item>
</style>
If all you're trying to do is a red action bar with a blue background, it is much easier to use the material properties included with v21+ of the support library:
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#color/red</item>
<item name="android:windowBackground">#color/blue</item>
</style>

Android : changing background for overflow menu in actionbar

I am trying to change the white background of overflow menu in action bar
I tried to assign a drawable that was generated using http://jgilfelt.github.io/android-actionbarstylegenerator/
I have defined the theme as below. But its not working and background is still white
Android 4.4.2
<style name="BoxTheme" parent="android:Theme.Holo.Light">
<!-- API 14 theme customizations can go here. -->
<item name="android:actionBarStyle">#style/BoxActionBar</item>
</style>
<style name="BoxActionBar" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#drawable/img_actionbar</item>
<item name="android:titleTextStyle">#style/colour.Text</item>
<item name="android:subtitleTextStyle">#style/colour.Text</item>
<item name="android:popupMenuStyle">#style/PopupMenu</item>
</style>
<style name="colour.Text" parent="#android:style/TextAppearance">
<item name="android:textColor">#color/white</item>
</style>
<style name="SpinnerColor" parent="android:style/Widget.Spinner">
<item name="android:dropDownSelector">#color/white</item>
</style>
<style name="PopupMenu" parent="android:style/Widget.Holo.Light.ListPopupWindow">
<item name="android:popupBackground">#drawable/menu_dropdown_panel</item>
</style>
Try this,
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:popupMenuStyle">#style/MyPopupMenu</item>
<item name="android:panelBackground">#android:color/holo_green_light</item>
<item name="android:actionBarWidgetTheme">#style/AppTheme</item>
</style>
<style name ="MyPopupMenu" parent="android:Theme.Holo.Light">
<item name="android:popupBackground">#android:color/holo_green_light</item>
</style>
And it could look like this

Change Color of Actionbar in Android

I am trying to change the background color of actionbar in my App but this is showing different on my app. Instead of coloring the actionbar the whole activity is color.
I am not sure why this is happening? I just want the main actionbar and settings actionbar colored.
Please check the screenshot.
Main Activity Map:
Preference Settings:
I also have transparent Actionbar with UP Navigation enabled for all my sub activities other than the main activity and preference settings activity.
I am not sure why it is showing like the above:
Here is style.xml (values-v14):
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<item name="android:background">#FF5050</item>
</style>
<style name="dialogtheme" parent="#android:style/Theme.Holo.Light.DarkActionBar"></style>
<!-- Transparent ActionBar Style -->
<style name="AppTheme.Light.ActionBar.Transparent" parent="#android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">#android:color/transparent</item>
</style>
<!-- Activity Theme with transparent ActionBar -->
<style name="AppTheme.TransparentActionBar.Light" parent="#style/AppBaseTheme">
<item name="android:actionBarStyle">#style/AppTheme.Light.ActionBar.Transparent</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:windowActionBarOverlay">true</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:displayOptions">showHome|homeAsUp|showTitle</item>
<item name="android:icon">#android:color/transparent</item>
<item name="android:actionBarTabTextStyle">#style/ActionBarTabTextStyle.Tabtheme</item>
<item name="android:actionBarDivider">#drawable/verticallinefordivder</item>
<item name="android:actionBarTabStyle">#style/ActionBarTabStyle.MapsLocation</item>
</style>
<style name="simpledialog" parent="android:Theme.Holo.Light.Dialog">
<item name="android:windowNoTitle">true</item>
</style>
<style name="ActionBarTabTextStyle.Tabtheme" parent="#style/AppBaseTheme">
<item name="android:textSize">18sp</item>
<item name="android:textStyle">bold</item>
<item name="android:textColor">#android:color/black</item>
</style>
<style name="ActionBarTabStyle.MapsLocations" parent="#android:style/Widget.Holo.Light.ActionBar.TabView">
<item name="android:background">#drawable/tab_indicator</item>
</style>
<style name="myPreferenceTheme" parent="#style/AppBaseTheme">
<item name="android:textColor">#color/blue</item>
</style>
<style name="Widget.ActionButton" parent="#style/AppBaseTheme">
<item name="android:background">?android:attr/actionBarItemBackground</item>
<item name="android:paddingLeft">12dip</item>
<item name="android:paddingRight">12dip</item>
<item name="android:minWidth">56dip</item>
<item name="android:minHeight">?android:attr/actionBarSize</item>
</style>
</resources>
A little change and you action bar will be red:
<style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<item name="android:actionBarStyle">#style/AppTheme.Light.ActionBar</item>
</style>
<style name="dialogtheme" parent="#android:style/Theme.Holo.Light.DarkActionBar"></style>
<!-- Transparent ActionBar Style -->
<style name="AppTheme.Light.ActionBar" parent="#android:style/Widget.Holo.ActionBar">
<item name="android:background">#FF5050</item>
</style>
I have changed item in AppBaseTheme & AppTheme.Light.ActionBar .
Now you are good to go. let me know if it works however working at my end :P
You can try set custom view in action bar.
actionBar.setDisplayShowCustomEnabled(true);
actionBar.setCustomView(you_custom_layout);
I know this is not right answer to this question but if you want to edit your ActionBar, you can use this online Android Action Bar Style Generator.
At least you can create a style and check yours to find differences and learn how to edit your ActionBar.

Dark ActionBar but Light PopMenu

I have a red actionbar and I'm using the DarkActionBar theme. But what I want is the popup menu in light colors. What I'm trying right now is something like this:
<style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<item name="android:windowTranslucentNavigation">false</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:actionBarStyle">#style/MyActionBar</item>
<item name="android:popupMenuStyle">#style/MyPopupMenu</item>
</style>
<style name="MyActionBar" parent="#android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">#android:color/transparent</item>
</style>
<style name="MyPopupMenu" parent="#android:style/Widget.Holo.Light.ListPopupWindow">
</style>
But the background of the menu is always black (I tried some other aproaches). I don't want to change it to Light ActionBar because the icon of the DarkActionBar fits bettes with the red color.
Ok I was able to solve it by myself. I have now a Light ActionBar but I changed the menu icon and the behavior of the focused items on the actionbar.
Here's what I did:
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
<item name="android:windowTranslucentNavigation">false</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:actionBarStyle">#style/MyActionBar</item>
<item name="android:actionOverflowButtonStyle">#style/MyButtonOverflow</item>
<item name="android:selectableItemBackground">#drawable/item_background_holo_dark</item>
</style>
<style name="MyActionBar" parent="#android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">#android:color/transparent</item>
</style>
<style name="MyButtonOverflow" parent="#android:style/Widget.Holo.ActionButton.Overflow">
<item name="android:src">#drawable/ic_menu_moreoverflow_normal_holo_dark</item>
</style>
I had to copy some resources of the android platform res folder, for example:
res/drawable/item_background_holo_dark.xml
res/drawable/list_selector_background_transition_holo_dark.xml
and some .9.png

Categories

Resources