I am working on an app which will be full-screen, but will utilize some of the functionalities of the ActionBar. With the Ice Cream Sandwhich release, I see that I get a blue line divider/separator as part of the ActionBar. Normally, it would be good for consistency, but in my case I need to remove the divider.
How can I remove or style the divider of the ActionBar in ICS?
Tried setting a custom theme with "android:style/Widget.Holo.ActionBar" as parent.
However, settings such as the one below has no effect
<item name="android:divider">#FFFFFF</item>
The graphic asset containing the blue bottom line is the background of the action bar's container view and is set to #android:drawable/ab_transparent_dark_holo when using the default Holo Dark theme.
To remove this line, you'll need to create a custom style for your action bar (based on Widget.Holo.ActionBar or Widget.Holo.Light.ActionBar (or the .Solid variants) and set the android:background to something that doesn't include the bottom border:
<style name="MyTheme" parent="android:Theme.Holo">
<item name="android:actionBarStyle">#style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="android:Widget.Holo.ActionBar">
<item name="android:background">#drawable/your_background_here</item>
</style>
Note: Holo Dark/Light action bars have solid and transparent styles; this blue line appears by default for the transparent style. Holo Dark action bars are transparent by default and Holo Light action bars are solid by default.
Here is a simple way to remove the divider, works from API 07 using the actionbarcompat from the support library:
#Override
public void onCreate(Bundle savedInstanceState) {
//...
getSupportActionBar().setBackgroundDrawable(
getResources().getDrawable(R.drawable.whatever_you_want));
//...
}
Changing the activity theme to Theme.Holo.Light.DarkActionBar removes the blue line.
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<item name="android:windowBackground">#android:color/black</item>
<item name="android:textColor">#android:color/white</item>
</style>
If you still want a black background you may want to change android:windowBackground and/or android:textColor
add this <item name="android:windowContentOverlay">#null</item> to your app theme.
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.
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.
How can I change the text color from the ActionBar in Android Lollipop to white from black ?
This is my current styling.
<style name="AppCustomTheme" parent="#style/Theme.AppCompat.Light">
<!-- colorPrimary is used for the default action bar background -->
<item name="colorPrimary">#color/orange_bar</item>
</style>
Use #style/Theme.AppCompat.Light.DarkActionBar to swap the coloring of text and many other attributes to better fit with a darker colored Action Bar.
I've read more and manage to find that you need to add this tag in order to change the ActionBar default color in Android Lollipop.
<!--textColorPrimary is used to change the text color of the default action bar-->
<item name="android:textColorPrimary">#FFFFFF</item>
Tested it on 5.0 Lollipop and 4.4 KitKat
<style name="MyAppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- To change action bar text color -->
<item name="android:textColorPrimary">#123</item>
<!-- This has to be here to make it work; let me know if you know why -->
<item name="actionBarTheme">#style/ThemeOverlay.AppCompat.ActionBar</item>
</style>
I have the theme Holo.Light.DarkActionBar
The tabs are now set to white background, light gray text--very unreadable. I simply want to change the text to something much, much darker.
I have searched the styles to see if I can override but all I can do is change the background, not the text.
Can I do this in the styles.xml or do I have to do this programmaticly?
If you're referring to the ActionBar's tab see if this changes the color:
<!-- The theme for the activity -->
<style name="TabSpecialTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<item name="#android:attr/actionBarTabTextStyle">#style/TabStyle</item>
</style>
<!-- Modify the text color -->
<style name="TabStyle" parent="android:Widget.Holo.Light.ActionBar.TabText.Inverse">
<item name="android:textColor">#F70000</item>
</style>
Of course don't forget to set the theme for the activity to #style/TabSpecialTheme in the manifest.
In my application I am using my own theme based on the Theme.Holo.Light
However I have customised the actionBarStyle, setting the background drawable to a blue gradient to fit with my app's style.
However, with the Halo light theme, the action bar text is dark, & the default icons, such as the Up Nav arrow and the menu icon are dark, these don't go on my blue gradient.
As you can see from my XML below, I have managed to correct the title text colour but I can't find the attribute I need to override for the icons.
How can I change tell the theme to effectively use the icons on the ActionBar from Theme.Halo
instead of those Theme.Halo.Light but making the rest of my application remain using Theme.Halo.Light
Here's my current XML
<style name="MyLightTheme" parent="android:Theme.Holo.Light">
<item name="android:actionBarStyle">#style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="android:style/Widget.Holo.ActionBar">
<item name="android:background">#drawable/blue_gradient_light</item>
<item name="android:titleTextStyle">#style/Theme.ActionBar.TitleTextStyle</item>
</style>
<style name="Theme.ActionBar.TitleTextStyle" parent="android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#color/solid_white</item>
</style>
Thanks for your help
Use Theme.Holo.Light.DarkActionBar as your base if you want to do this. It will take care of these details.