Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I change the text of the Material Design ActionBar?

I'm playing around a bit to make an Android app using the new Material Design, but I can't figure out how to change the color of the text on the ActionBar.

I have this:

<style name="AppTheme" parent="@android:style/Theme.Material.Light">
    <item name="android:colorPrimary">#ff3d00</item>
    <item name="android:colorPrimaryDark">#dd2c00</item>
    <item name="android:colorAccent">#ff3d00</item>
</style>

But that looks like this:

enter image description here

I don't really like the black text on the orange background. I tried to do this:

<style name="AppTheme" parent="@android:style/Theme.Material">
    <item name="android:colorPrimary">#ff3d00</item>
    <item name="android:colorPrimaryDark">#dd2c00</item>
    <item name="android:colorAccent">#ff3d00</item>
</style>

And that looks like this:

enter image description here

As you can see, the color of the ActionBar text did change, but the background became grey, which I don't like.

How exactly am I supposed to do this? Thanks in advance!

like image 718
jvnknvlgl Avatar asked Jun 30 '14 15:06

jvnknvlgl


People also ask

How do I add text to action bar?

Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml. In the above code, we have taken text view to show status bar tittle.

What is an action bar?

Android ActionBar is a menu bar that runs across the top of the activity screen in android. Android ActionBar can contain menu items which become visible when the user clicks the “menu” button.


1 Answers

I think in this case it's enough to change the style to Theme.Material.Light.DarkActionBar. You'll get the light interface elements, but a 'dark' ActionBar with a light title text.

like image 165
SanderTuit Avatar answered Oct 11 '22 11:10

SanderTuit