I am trying to modify the text color of the title of the ActionBarSupport. I have used ActionBarStyleGenererator to create a theme with the correct colors and it works well.
While using the light theme, I would like to change the color of the heading to white (in the genererator I cannot set the text color(. For a number of reasons I cannot use the dark actionbar theme. I am so close, just have to get the title to white ;-)
What I am doing wrong here?
<style name="ActionBar.Transparent.MyApp" parent="#style/Widget.AppCompat.Light.ActionBar">
<item name="background">#drawable/ab_transparent_myapp</item>
<item name="progressBarStyle">#style/ProgressBar.MyApp</item>
<item name="titleTextStyle">#style/MyApp.TitleTextStyle</item>
</style>
<style name="MyApp.TitleTextStyle" parent="#style/TextAppearance.AppCompat.Widget.Base.ActionBar.Title">
<item name="android:textColor">#ffffff</item>
</style>
The below code worked for me. I hope it will help you tooo.
<style name="AppTheme" parent="AppBaseTheme">
<item name="actionBarStyle">#style/ActionBarCompat</item>
</style>
<style name="ActionBarCompat" parent="#style/Widget.AppCompat.Base.ActionBar">
<item name="titleTextStyle">#style/titleStyle</item>
</style>
<style name="titleStyle" parent="#style/TextAppearance.AppCompat.Widget.Base.ActionBar.Title">
<item name="android:textColor">#android:color/white</item>
</style>
Embarrassing. I was not paying attention to the values-v14/-folder (which overrides the vales/) ActionBarStyleGenererator created. Using the android-prefix on the styles in values-v14 it worked:
<item name="android:titleTextStyle">#style/titleTextStyle</item>
Found at Overflow styling
I've been trying to keep the ActionBar title text color through orientation changes without much luck until I got a clue from the above site. I applied the Spannable to to the title. Here's what i do when setting up my ActionBar:
Spannable actionBarTitle = new SpannableString("Action Bar Title");
actionBarTitle.setSpan(
new ForegroundColorSpan(Color.WHITE),
0,
actionBarTitle.length(),
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
mActionBar.setTitle(actionBarTitle);
This needs to be executed on orientation change. I call it from onCreate()...don't know if it works in onConfigurationChange().
#TNR is correct, however you should double check if your layout xml file has not overriden the android:theme attribute with a different style.
This usually happens if you have generated layout files
Related
Android L uses white background for notifications and grey color for the text on it. But, "#android:style/TextAppearance.StatusBar.EventContent.Title" still sets the color of TextView to same white color like in KitKat or previous versions. It should return the grey color used in new notification style of Android L.
How can I solve it? Thanks in advance.
It seems android-L doesn't override "#android:style/TextAppearance.StatusBar.EventContent.Title", instead introduces new style
<style name="TextAppearance.Material.Notification.Title">
<item name="textColor">#color/primary_text_default_material_light</item>
<item name="textSize">#dimen/notification_title_text_size</item>
</style>
We could make use of both the API based values folders to handle this in proper way.
/values/styles.xml
<style
name="NotificationTitle"
parent="#style/TextAppearance.StatusBar.EventContent.Title" />
/values-21/styles.xml
<style
name="NotificationTitle"
parent="#android:style/TextAppearance.Material.Notification.Title" />
Now call the following line in your TextView
android:textAppearance="#style/NotificationTitle"
Here is what worked for me to resolve this error. In your styles.xml, add the following:
<style name="TextAppearance">
</style>
<style name="TextAppearance.StatusBar">
</style>
<style name="TextAppearance.StatusBar.EventContent">
<item name="android:textColor">#ff6b6b6b</item>
</style>
<style name="TextAppearance.StatusBar.EventContent.Info">
<item name="android:textColor">#ff6b6b6b</item>
</style>
trying to change actionbar text color of this item in the action bar. here is the item
<item android:id="#+id/options_button"
android:title="#string/options"
android:showAsAction="ifRoom|withText"/>
and here is my styles.xml
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="MyCustomTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/MyActionBarTheme</item>
<item name="android:background">#color/White</item>
<item name="android:textColor">#color/Red</item>
</style>
<style name="MyActionBarTheme" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#color/White</item>
<item name="android:textColor">#color/Red</item>
</style>
</resources>
i saw other posts on here about this but after trying their solutions nothing worked for me? is it something to do with how i made the theme? All i really wanted was my action bar to be white, not display the title, and display a button that says options. I have all of that, but the options I want to be a red color im working with rather than black.
dont think people understand...
I know of the way to change the title (I dont have a title and i dont want one).I want to change the color of the item that is displaying itself in the actionbar...
I have faced the same issue, but I found a solution that doing well with any type of ActionBar (Native, Sherlock or Compat)
Actually you can use HTML code to set the title, and specify the text color. For example, to set the ActionBar text color to red, simply do this:
getActionBar()/* or getSupportActionBar() */.setTitle(Html.fromHtml("<font color=\"red\">" + getString(R.string.app_name) + "</font>"));
You can also use hex code of red color #FF0000 instead of the word red.
But, Setting a HTML string on the action bar doesn't work on the Material theme in SDK v21+.
If you want to change it you should set the primary text color in your style.xml as below.
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="android:Theme.Material.Light">
<!-- Customize your theme here. -->
<item name="android:textColorPrimary">#color/actionbar-text-color</item>
May this helps you.
I followed this Guide to style my ActionBar. I use fixed tabs in my app so I want to theme the tabs too.
(Note: I'm using the appcompat theme to ensure some backwards compatibility)
So I used
<style
name="CustomTheme"
parent="#style/Theme.AppCompat.Light" >
<item name="android:actionBarStyle">#style/CustomActionBar</item>
<item name="actionBarStyle">#style/CustomActionBar</item>
<item name="android:actionBarTabStyle">#style/CustomActionBarTabs</item>
<item name="actionBarTabStyle">#style/CustomActionBarTabs</item>
</style>
as my theme.
I set the ActionBar background without problems, but then I tried theming the tabs with:
<style
name="CustomActionBarTabs"
parent="#style/Widget.AppCompat.ActionBar.TabView" >
<item name="android:background">#drawable/customtheme_actionbar_tab_indicator</item>
<item name="background">#drawable/customtheme_actionbar_tab_indicator</item>
</style>
The background points to a StateList where I set different drawables for different contexts, which works kind of as expected. Except it works just for the tabs. Not for the ActionBar.
The separator and the background of the tab bar is not themed.
How can I theme those ? (The grey part)
Theme Creation Guidelines
I wonder if there are any guidelines for creating a theme that looks good ?
(good = similar to default theme, so the app fits into the android ecosystem)
Because If you look closely at the default themes you can see a small line at the bottom of the ActionBar drawable. (The part which is light green in my theme)
There may be other things which you should consider when creating a theme that looks similar to the default themes, so it would be nice to some guideline.
Also: Should the TabBar always be darker than the ActionBar ?
(If so, how much darker?)
How much brighter/darker than the ActionBar color should the image color (like the color of the overflow button in the image) be ?
Thanks in advance,
Uriel
Add this
<style
name="CustomTheme"
parent="#style/Theme.AppCompat.Light" >
.
.
.
<item name="android:actionBarTabBarStyle">#style/TabBar</item>
</style>
And then
<style name="TabBar" parent="#style/Widget.AppCompat.ActionBar.TabBar">
<item name="android:background">/** Whatever color you want, like #ffff00 **/</item>
</style>
Just incase, it may help somebody
This below worked for me
<style name="Theme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="actionBarTabStyle">#style/Theme.MyActionBarTab</item>
<item name="actionBarTabTextStyle">#style/Theme.MyActionBarTabText</item>
</style>
<style name="Theme.MyActionBarTab" parent="#style/Widget.AppCompat.ActionBar.TabView">
<item name="android:background">#color/gray_mask</item>
</style>
<style name="Theme.MyActionBarTabText" parent="Widget.AppCompat.Light.ActionBar.TabText">
<item name="android:textColor">#color/black</item>
<item name="android:textSize">#dimen/size_28</item>
<item name="android:gravity">center</item>
<item name="textAllCaps">false</item>
</style>
I'm using a custom theme that inherits from DarkActionBar and I want to customize dropdown menu to be white like when using Light Holo theme.
I've been able to change the background to white using:
<style name="MyTheme" parent="#style/Theme.Light.DarkActionBar">
<item name="android:actionDropDownStyle">#style/MyDropDownNav</item>
</style>
<style name="MyDropDownNav">
<item name="android:background">#drawable/spinner_background_white</item>
<item name="android:popupBackground">#drawable/menu_dropdown_panel_whyite</item>
<item name="android:dropDownSelector">#drawable/selectable_background_white</item>
</style>
But I haven't any clue of how to change the text color to black. Because after setting white drawable the problem is that text isn't visible because is white on white background.
I answer myself after some investigation.
In addition to question's styling you need to:
Customize android:spinnerDropDownItemStyle for actionBarWidgetTheme changing it's text appearance.
Also don't forget that dropdown list is managed by the adapter you use. Then if you used the standard one (simple_dropdown_item_1line) there's no problem. But if you used a custom one like me (to be able to add an icon) don't forget to apply style="?attr/spinnerDropDownItemStyle" in your layout TextView.
Then final custom style is:
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="Theme.myapp" parent="#style/Theme.Light.DarkActionBar">
<item name="android:actionDropDownStyle">#style/myapp_DropDownNav</item>
<item name="android:actionBarWidgetTheme">#style/myapp.actionBarWidgetTheme</item>
</style>
<style name="myapp.actionBarWidgetTheme" parent="#style/Theme.">
<item name="android:spinnerDropDownItemStyle">#style/myapp.Widget.DropDownItem.Spinner</item>
</style>
<style name="myapp_DropDownNav" parent="#style/Widget.Spinner.DropDown.ActionBar">
<item name="background">#drawable/spinner_background_ab_myapp</item>
<item name="android:background">#drawable/spinner_background_ab_myapp</item>
<item name="android:popupBackground">#drawable/menu_dropdown_panel_myapp</item>
<item name="android:dropDownSelector">#drawable/selectable_background_myapp</item>
</style>
<style name="myapp.Widget.DropDownItem.Spinner" parent="Widget.DropDownItem.Spinner">
<item name="android:textAppearance">#style/myapp.TextAppearance.Widget.DropDownItem</item>
</style>
<style name="myapp.TextAppearance.Widget.DropDownItem" parent="TextAppearance.Widget.DropDownItem">
<item name="android:textColor">#color/black</item>
</style>
Where drawables in myapp_DropDownNav are white background ones that you can generate with ActionBar Style generator in Android Asset Studio
Try setting itemTextAppearance. That should achieve what you want.
I have stumbled on what may be the simplest way to do this. I was working with the AppCompat library.
<style name="ApplicationTheme" parent="#style/Theme.AppCompat">
<item name="android:actionBarWidgetTheme">#style/Theme.AppCompat.Light</item>
<item name="actionBarWidgetTheme">#style/Theme.AppCompat.Light</item>
</style>
My advice is to simply inherit from the Sherlock.Light theme and change the applicable fields to the Dark values. For my app, we wanted a white "up" icon, and white text for the action labels. I don't provide dark versions of my actionbar icons, so they are all white anyway. So after several hours messing around with it and following different people's suggestions, I finally found what I was looking for in the ABS themes file.
I inherit from Sherlock.Light (well, technically HoloEverywhereLight.Sherlock but...) and change:
<item name="android:actionMenuTextColor">#color/White</item>
<item name="actionMenuTextColor">#color/White</item>
<item name="android:homeAsUpIndicator">#drawable/abs__ic_ab_back_holo_dark</item>
<item name="homeAsUpIndicator">#drawable/abs__ic_ab_back_holo_dark</item>
<item name="android:dividerVertical">#drawable/abs__list_divider_holo_dark</item>
<item name="dividerVertical">#drawable/abs__list_divider_holo_dark</item>
That's it. It's way simpler and easier than trying to extend classes, restyle things in code, etc.
I am trying to theme an ActionBar in xml rather than code. So far I have this:
<style name="TestTheme" parent="android:Theme.Holo.Light">
<item name="android:actionBarStyle">#style/TestActionBar</item>
</style>
<style name="TestActionBar" parent="android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#drawable/actionbar_background</item>
</style>
This is giving me my custom background and I want to be able to turn off the title here as well. In code, I would set setDisplayShowTitleEnabled to false. How do I do it in xml?
ok, here is the answer. Adding this to the second style block above hid the titles.
<item name="android:displayOptions">showHome|useLogo</item>