I'm trying change my ActionBar style, changing the background and title color. The background is ok, but when I try change the titleTextStyle the title that I defined on manifest disappear.
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/primary</item>
<item name="colorPrimaryDark">#color/primary_dark</item>
<item name="colorAccent">#color/accent</item>
<item name="android:actionBarStyle">#style/AppTheme.ActionBarStyle</item>
<item name="actionBarStyle">#style/AppTheme.ActionBarStyle</item>
</style>
<style name="AppTheme.ActionBarStyle" parent="#android:style/Theme.Holo.Light.DarkActionBar">
<item name="android:background">#color/dark</item>
<item name="background">#color/dark</item>
<item name="android:textColor">#color/icons</item>
<item name="android:displayOptions">showHome|showTitle|useLogo</item>
<item name="android:titleTextStyle">#style/AppTheme.ActionBar.TitleStyle</item>
<item name="titleTextStyle">#style/AppTheme.ActionBar.TitleStyle</item>
</style>
<style name="AppTheme.ActionBar.TitleStyle" parent="#android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#color/icons</item>
</style>
I have another doubt about the color of default icons. For example, I'm using NavigationDrawer and would like to change the color of your icon
That worked for me:
getSupportActionBar().setDisplayShowTitleEnabled(true);
Related
I having this weird behavior with the styling of ActionBar and Snackbar.
I have below theme for AppTheme
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorWhite</item>
<item name="colorPrimaryDark">#color/colorWhiteDark</item>
<item name="colorAccent">#color/colorGreen</item>
</style>
So, I am having white theme. And my SnackBar looks like this
But, whenever I add custom actionBarTheme, like
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorWhite</item>
<item name="colorPrimaryDark">#color/colorWhiteDark</item>
<item name="colorAccent">#color/colorGreen</item>
<item name="actionBarTheme">#style/ActionbarTheme</item>
</style>
<style name="ActionbarTheme">
<item name="android:textColor">#color/colorBlack</item>
<item name="android:background">#color/colorWhite</item>
</style>
My SnackBar looks like this
Why it is causing this behavior and how to fix it?
Since you are applying following style in your parent
<style name="ActionbarTheme">
<item name="android:textColor">#color/colorBlack</item>
<item name="android:background">#color/colorWhite</item>
</style>
Your text color is black and your background is white.
EDIT:
To fix, you need to set textcolor as white and background black:
<style name="ActionbarTheme">
<item name="android:textColor">#color/colorWhite</item>
<item name="android:background">#color/colorBlack</item>
</style>
change item name background to colorPrimary
<style name="ActionbarTheme">
<item name="android:textColor">#color/colorBlack</item>
<item name="colorPrimary">#color/colorWhite</item>
</style>
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>
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>
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.
I am trying to change the drop down background of the sherlock action bar as well as its text color. Here's what I have tried:
<style name="DropDown" parent="Widget.Sherlock.Spinner.DropDown.ActionBar">
<item name="android:popupBackground">#EDEDED</item>
</style>
<style name="TextAppearance" parent="TextAppearance.Sherlock.Widget.TextView.SpinnerItem">
<item name="android:textColor">#A9A9A9</item>
</style>
<style name="SpinnerItemStyle" parent="Widget.Sherlock.TextView.SpinnerItem">
<item name="android:textAppearance">#style/TextAppearance</item>
</style>
<style name="MyTheme" parent="#style/devcheckStyle">
<item name="android:actionDropDownStyle">#style/DropDown</item>
<item name="actionDropDownStyle">#style/DropDown</item>
<item name="spinnerItemStyle">#style/SpinnerItemStyle</item>
<item name="android:spinnerItemStyle">#style/SpinnerItemStyle</item>
</style>
The main theme being MyTheme, with the following code I am getting the desirable background color, but I am getting nowhere with the text's color inside the drop down navigation. Can someone please help.
Put that code
<item name="android:textColor">#ffffffff</item>
into your MyTheme code should be like:
<style name="MyTheme" parent="#style/devcheckStyle">
<item name="android:actionDropDownStyle">#style/DropDown</item>
<item name="actionDropDownStyle">#style/DropDown</item>
<item name="spinnerItemStyle">#style/SpinnerItemStyle</item>
<item name="android:spinnerItemStyle">#style/SpinnerItemStyle</item>
</style>