Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

change action bar title color Theme.AppCompat.Light.DarkActionBar android

I wants to change the action bar title color to white in android . and i am using theme in values Theme.AppCompat.Light and values-14 Theme.AppCompat.Light.DarkActionBar
I have tried so far in values folder :

<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
    <item name="actionBarStyle">@style/MyActionBar</item>
</style>

<style name="MyActionBar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
    <item name="android:textColor">@android:color/white</item>
</style>

and values -14 folder

  <style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="actionBarStyle">@style/MyActionBar</item>
</style>

<!-- ActionBar styles -->
<style name="MyActionBar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
    <item name="android:textColor">@android:color/white</item>
</style>

but ActionBar title color is not changing.

like image 839
John Avatar asked Jan 19 '15 14:01

John


People also ask

How to style action bar android?

You can define the color of the ActionBar (and other stuff) by creating a custom Style: Simply edit the res/values/styles. xml file of your Android project. Then set "MyCustomTheme" as the Theme of your Activity that contains the ActionBar.

How do I change the color of the text in Actionbar?

Customize the Text Color To modify the color of text in the action bar, you need to override separate properties for each text element: Action bar title: Create a custom style that specifies the textColorproperty and specify that style for the titleTextStyleproperty in your custom actionBarStyle.

How can I change the action bar style?

If you want to style the action bar to better fit your product brand, you can easily do so using Android's style and themeresources. Android includes a few built-in activity themes that include "dark" or "light" action bar styles. You can also extend these themes to further customize the look for your action bar.

How do I add a dark theme to an activity?

You can also use a dark action bar while the rest of the activity uses the light color scheme by declaring the Theme.Holo.Light.DarkActionBartheme. When using the Support Library, you must instead use the Theme.AppCompatthemes: Theme.AppCompatfor the "dark" theme.

How do I apply a style as a theme in Android?

Apply a style as a theme. You can create a theme the same way you create styles. The difference is how you apply it: instead of applying a style with the style attribute on a view, you apply a theme with the android:theme attribute on either the <application> tag or an <activity> tag in the AndroidManifest.xml file.


2 Answers

You can specify the background color of the ActionBar by using the colorPrimary attribute; something like the following:

    <style name="AppBaseTheme" parent="Theme.AppCompat.Light">
    <item name="colorPrimary">@android:color/white</item>
    </style>

The above is a special tag created for AppCompat; you will notice that the android: namespace is omitted.

like image 175
Willis Avatar answered Oct 13 '22 06:10

Willis


If you are using Theme.AppCompat.Light.NoActionBar do

<android.support.v7.widget.Toolbar  xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_height="wrap_content"
    android:layout_width="match_parent"
    android:minHeight="?attr/actionBarSize"
    android:background="@color/background_material_dark"
    app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
like image 23
vintuwei Avatar answered Oct 13 '22 06:10

vintuwei