I've tried everything I've found to change Actionbar Tab's text color. I've come up with this:
<resources xmlns:tools="http://schemas.android.com/tools">
<style name="AppTheme" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionBarStyle">#style/ActionBar</item>
<!-- Support library compatibility -->
<item name="actionBarStyle">#style/ActionBar</item>
</style>
<!-- ActionBar styles -->
<style name="ActionBar"
parent="#style/Widget.AppCompat.Light.ActionBar">
<!-- Support library compatibility -->
<item name="background">#color/actionbar_background</item>
<item name="titleTextStyle">#style/ActionBarTitleText</item>
<item name="actionBarTabTextStyle">#style/ActionBarTabText</item>
<item name="displayOptions">showHome|showTitle</item>
<item name="logo">#drawable/actionbar_logo</item>
</style>
<!-- ActionBar title text -->
<style name="ActionBarTitleText"
parent="#style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">#color/actionbar_text</item>
<item name="android:textSize">#dimen/text_size_large</item>
</style>
<!-- ActionBar TABs -->
<style name="ActionBarTabText"
parent="#style/Widget.AppCompat.ActionBar.TabText">
<item name="android:textColor">#color/actionbar_tab_text</item>
<item name="android:textSize">#dimen/text_size_medium</item>
<item name="android:textAllCaps">false</item>
</style>
</resources>
Still actionbar tabs show white textcolor and uppercase texts.
Any idea what could be possibly going wrong?
If you are using a android.support.v7.widget.Toolbar, then remove below two lines from your layout file,
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:popupTheme="#style/ThemeOverlay.AppCompat.Light"
This should solve your problem.
Try adding the "android:" versions of these two lines.
#style/ActionBarTabText
showHome|showTitle
Related
I am using "Theme.Light" theme for my android project and while setting up a navigation drawer how can i set actionbar size(height).
I used the below code and i got an error..
<style name="Theme.Light.ActionBar" parent="#android:style/Theme.Light">
<item name="android:windowNoTitle">false</item>
<item name="android:windowActionBar">true</item>
<item name="actionBarSize">36dip</item>
<item name="android:windowActionBarOverlay">true</item>
</style>
can you please reply to my problem as soon as possible and thank you.
Use height attribute,for actionBarHeight
<item name="android:height">#dimen/bar_height</item>
you have to create style like this:
<!-- Application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light">
<!-- Main theme colors -->
<!-- your app branding color for the app bar -->
<item name="colorPrimary">#color/primary</item>
<!-- darker variant for the status bar and contextual app bars -->
<item name="colorPrimaryDark">#color/primary_dark</item>
<!-- theme UI controls like checkboxes and text fields -->
<!-- native widgets will now be "tinted" with accent color -->
<item name="colorAccent">#color/accent</item>
<!--Action bar style-->
<item name="android:actionBarStyle">#style/AppTheme.ActionBar</item>
<item name="actionBarStyle">#style/AppTheme.ActionBar</item>
</style>
<style name="AppTheme.ActionBar" parent="Widget.AppCompat.Light.ActionBar">
<item name="titleTextStyle">#style/AppTheme.ActionBar.TitleText</item>
<item name="android:titleTextStyle">#style/AppTheme.ActionBar.TitleText</item>
<item name="android:height">#dimen/bar_height</item>
</style>
<style name="AppTheme.ActionBar.TitleText" parent="TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textSize">#dimen/bar_text_size</item>
<item name="android:textColor">#color/bar_text_color</item>
</style>
you have to try below code :
<resources>
<style name="Theme.FixedSize" parent="#android:style/Theme.Holo.Light.DarkActionBar">
<item name="actionBarSize">48dip</item>
<item name="android:actionBarSize">48dip</item>
</style>
</resources>
If you are using AppCompat, you can set the "actionBarSize" attribute in your theme (which must inherit from Theme.AppCompat.x). You can also use a Toolbar in your layout and set its layout_height to the desired value.
styles.xml
<resources>
<style name="CustomTheme" parent="Theme.AppCompat.Light">
<item name="android:actionBarStyle">#style/CustomBar</item>
<item name="actionBarStyle">#style/CustomBar</item>
</style>
<style name="CustomBar" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:background">#color/black</item>
<item name="android:src">#drawable/home</item>
<item name="background">#color/black</item>
<item name="src">#drawable/home</item>
</style>
</resources>
The Above code doesn't work as android:src is not found, however i wish to achieve the intended effect of this.
I have a company logo that i want to use as the action bar main image, but don't want to use static image for full background colouring. The logo image, #drawable/home has a transparent background.
How would i style the action bar to include an image as well as a background colour?
I don`t know that we have src, here is the code what worked for me:
to set the image this is what I use:
<item name="android:background">#drawable/headerflowerimage</item>
Please find the whole code here:
<!-- the theme applied to the application or activity -->
<style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionBarStyle">#style/SActionBar</item>
<!--- Support library compatibility-->
<item name="actionBarStyle">#style/SActionBar</item>
<item name="android:actionBarTabStyle">#style/STabBars</item>
<!-- Support library compatibility -->
<item name="actionBarTabStyle">#style/STabBars</item>
</style>
<!-- ActionBar tabs styles -->
<style name="STabBars" parent="#style/Widget.AppCompat.ActionBar.TabView">
<!-- tab indicator -->
<item name="android:background">#color/tabbar_background</item>
<item name="android:backgroundStacked">#color/background_material_light</item>
<item name="android:actionBarTabTextStyle">#color/greyrish_s</item>
<!-- Support library compatibility -->
<item name="background">#color/tabbar_background</item>
<item name="backgroundStacked">#color/background_material_light</item>
<item name="actionBarTabTextStyle">#color/greyrish_s</item>
</style>
<!-- ActionBar styles -->
<style name="SActionBar" parent="#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background">#drawable/headerflowerimage</item>
<item name="android:titleTextStyle">#style/sTitleColor</item>
<item name="android:displayOptions">showTitle</item>
<!-- Support library compatibility -->
<item name="background">#drawable/headerflowerimage</item>
<item name="titleTextStyle">#style/sTitleColor</item>
<item name="displayOptions">showTitle</item>
</style>
I already read many ways to change spinner textColor in an ActionBar, but I really can't figure it out what is missing to make what I need.
This is how I have my actionbar spinner:
As you can see, I have white text on spinner items. I need to change it to black.
My res/styles file is this one.
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="AppBaseTheme" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<!-- API 14 theme customizations can go here. -->
<item name="android:dropDownListViewStyle">#style/MyDropDownListView</item>
<item name="android:dropDownItemStyle">#style/MyDropDownItemView</item>
<!-- <item name="android:textColor">#color/white</item> -->
</style>
<!-- ActionBar styles -->
<style name="MyDropDownListView" parent="#style/Widget.AppCompat.ListView.DropDown">
<item name="android:background">#color/white</item>
</style>
</resources>
I changed background to white, but now i need to change text to black and I can't do it.
Some one can help me?
I think the easiest way is to create a custom spinner item layout for your spinner, but with only a textview & it's color set to whatever you want it to be.
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:textSize="14sp"
android:textColor="#000000" />
Here is also a post that explains how to do it by changing the xml styles: Android Actionbar navigation spinner text color
UPDATE:
Remove the "android:" part from the xml statments that change something from the appcompat library. In my app it did the trick. So instead of this:
<style name="AppBaseTheme" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<!-- API 14 theme customizations can go here. -->
<item name="android:dropDownListViewStyle">#style/MyDropDownListView</item>
<item name="android:dropDownItemStyle">#style/MyDropDownItemView</item>
<!-- <item name="android:textColor">#color/white</item> -->
</style>
You remove the "android:" part:
<style name="AppBaseTheme" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<!-- API 14 theme customizations can go here. -->
<item name="dropDownListViewStyle">#style/MyDropDownListView</item>
<item name="dropDownItemStyle">#style/MyDropDownItemView</item>
<!-- <item name="textColor">#color/white</item> -->
</style>
UPDATE 2:
So i'll just post how i style my appcompat apps, so maybe you can see what i don't see. I have 2 folders: resources/values & resources/values-v14.
In the resource/value my style.xml file looks like this:
<style name="Theme.Jamesstyle" parent="#style/Theme.AppCompat.Light">
<item name="actionBarStyle">#style/Actionbar.FlatUi</item>
<item name="actionBarTabStyle">#style/ActionBar.FlatUi.Tabs</item>
<item name="actionBarTabTextStyle">#style/ActionBar.FlatUi.Text</item>
<item name="homeAsUpIndicator">#android:color/transparent</item>
</style>
<style name="Actionbar.FlatUi" parent="#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="background">#color/bizzumi_light</item>
<item name="backgroundStacked">#color/bizzumi_red</item>
<item name="backgroundSplit">#color/bizzumi_red</item>
<item name="titleTextStyle">#style/TitleColor</item>
<item name="displayOptions">showHome|homeAsUp|showTitle</item>
</style>
<style name="TitleColor" parent="#style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="textColor">#000099</item>
</style>
And in my resources/values-v14 style.xml file i have:
<style name="Theme.Jamesstyle" parent="#style/Theme.AppCompat.Light">
<item name="android:actionBarStyle">#style/Actionbar.FlatUi</item>
<item name="android:actionBarTabStyle">#style/ActionBar.FlatUi.Tabs</item>
<item name="android:homeAsUpIndicator">#android:color/transparent</item>
<item name="android:actionBarTabTextStyle">#style/ActionBar.FlatUi.Text</item>
</style>
<style name="Actionbar.FlatUi" parent="#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background">#color/bizzumi_light</item>
<item name="android:backgroundStacked">#color/bizzumi_light</item>
<item name="android:backgroundSplit">#color/bizzumi_light</item>
<item name="android:titleTextStyle">#style/TitleColor</item>i
<item name="android:displayOptions">showHome|homeAsUp|showTitle</item><item name="displayOptions">showHome|homeAsUp|showTitle</item></style>
<style name="TitleColor" parent="#style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">#000099</item>
</style>
Maybe try this folder structure and create 2 different styles.xml files. Otherwise i'm clueless. Good luck!
`<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="AppBaseTheme" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<!-- API 14 theme customizations can go here. -->
<item name="android:dropDownListViewStyle">#style/MyDropDownListView</item>
<item name="android:dropDownItemStyle">#style/MyDropDownItemView</item>
<!-- <item name="android:textColor">#color/white</item> -->
</style>
<!-- ActionBar styles -->
<style name="MyDropDownListView" parent="#style/Widget.AppCompat.ListView.DropDown">
<item name="android:background">#color/white</item>
<item name="android:textColor">#000000</item>
</style>
I have been trying to set white text on the actionbar. I went through many questions and I am using theme Theme.AppCompat.Light.DarkActionBar and currently using this xml:
<style name="TrasnparentActionBarTheme" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionBarStyle">#style/TransparentActionBar</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowActionBarOverlay">true</item>
</style>
<style name="TransparentActionBar" parent="#style/Widget.AppCompat.ActionBar">
<item name="android:background">#drawable/actionbar_transparent_background</item>
<item name="android:titleTextStyle">#style/TransparentTransparentActionBarText</item>
</style>
<style name="TransparentTransparentActionBarText" parent="#style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">#android:color/white</item>
</style>
I have tried different combinations for eg: setting android:titleTextStyle, actionmenutextcolor, or using the actionBar Style Generator. None are working for me.
The above code is from values-v11 but a similar code is in values folder too.
#drawable/actionbar_transparent_background is just a shape with <solid android:color="#00000000"/>
In order to have white text (so dark action bar with light theme) you have to inherit your actionbar style from the correct object: Widget.AppCompat.Light.ActionBar.Solid.Inverse and not Widget.AppCompat.ActionBar.Solid
Here is the style.xml file :
<resources>
<style name="AppTheme" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<!-- action bar -->
<item name="actionBarStyle">#style/MyActionBar</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar"
parent="#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background">#drawable/actionbar_background</item>
<!-- Support library compatibility -->
<item name="background">#drawable/actionbar_background</item>
</style>
</resources>
I am using support library to add an action bar.
in res/values/styles:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme" parent="android:Theme"></style>
<style name="Theme.Transparent">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowAnimationStyle">#android:style/Animation.Translucent</item>
<item name="android:windowBackground">#drawable/transparent_background</item>
<item name="android:windowNoTitle">true</item>
<item name="android:colorForeground">#fff</item>
</style>
<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme"
parent="#style/Theme.AppCompat">
<item name="android:actionBarStyle">#style/MyActionBar</item>
<item name="android:actionBarTabTextStyle">#style/MyActionBarTabText</item>
<item name="android:actionMenuTextColor">#color/actionbar_text</item>
<!-- Support library compatibility -->
<item name="actionBarStyle">#style/MyActionBar</item>
<item name="actionBarTabTextStyle">#style/MyActionBarTabText</item>
<item name="actionMenuTextColor">#color/actionbar_text</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar"
parent="#style/Widget.AppCompat.ActionBar">
<item name="android:titleTextStyle">#style/MyActionBarTitleText</item>
<!-- Support library compatibility -->
<item name="titleTextStyle">#style/MyActionBarTitleText</item>
</style>
<!-- ActionBar title text -->
<style name="MyActionBarTitleText"
parent="#style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">#color/actionbar_text</item>
<!-- The textColor property is backward compatible with the Support Library -->
</style>
<!-- ActionBar tabs text -->
<style name="MyActionBarTabText"
parent="#style/Widget.AppCompat.ActionBar.TabText">
<item name="android:textColor">#color/actionbar_text</item>
<!-- The textColor property is backward compatible with the Support Library -->
</style>
</resources>
and then when i add this
application android:theme="#style/CustomActionBarTheme"
to mainfest, the application falls to start. if i removed it the application works perfectly
help pelase
Try using: Action bar stylle generator. It's simple and works perfectly for default, ActionBarSherlock, Holoeverywhere themes.