0

I am new to Android development. The app on which I am working requires white action bar background and the title should be black in color. I am using support library for lower compatibility.

Style.xml

<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
     <!-- Customize your theme here. -->
</style>

How can I do this ?

Jonas Czech
  • 12,018
  • 6
  • 44
  • 65
Anuj Mody
  • 21
  • 1
  • 6

3 Answers3

3

Styles : Main App Theme

<style name="MyAppTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">

    <item name="android:actionBarStyle">@style/CustomActionBarStyle</item>
  <!-- Support library compatibility -->  
    <item name="actionBarStyle">@style/CustomActionBarStyle</item>

</style>

Setup styles for text and background color

<style name="CustomActionBarStyle" parent="@style/Widget.AppCompat.Light.ActionBar">
    <item name="android:background">@color/white</item>
    <item name="android:titleTextStyle">@style/MyActionBarTitleText</item>

    <item name="background">@color/white</item>
    <item name="titleTextStyle">@style/MyActionBarTitleText</item>
</style>

Setup TextColor Impt: parent must @style/TextAppearance.AppCompat.Widget.ActionBar.Title

<style name="MyActionBarTitleText" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
    <item name="android:textColor">@color/action_bar_text_color</item>
</style>

For more refer links posted in @Santosh Shinde post

Bharatesh
  • 8,943
  • 3
  • 38
  • 67
3

Use This to change title color

ActionBar actionBar = getActionBar();
         actionBar.setTitle(Html
         .fromHtml("<font color='#ffffff'> Now playing </font>"));

and for action bar title

getActionBar().setBackgroundDrawable(
         new ColorDrawable(Color.rgb(0, 0, 0)));

or

getActionBar().setBackgroundDrawable(
         new ColorDrawable(Color.parseColor("#000000")));
Quick learner
  • 10,632
  • 4
  • 45
  • 55
0

Try this style:

<style name="AppTheme" parent="android:Theme.Material.Light.DarkActionBar">
    <item name="android:actionBarStyle">@style/ActionBar</item>
    <item name="android:buttonStyle">@style/Button</item>
    <item name="android:editTextStyle">@style/EditText</item>
    <item name="android:windowBackground">@android:color/black</item>
</style>

<style name="ActionBar" parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
    <item name="android:backgroundStacked">@color/core_other_light</item>
    <item name="android:backgroundSplit">@color/core_other</item>
    <item name="android:background">#00ff00</item>
</style>

You can find more information here and here.

Xaver Kapeller
  • 49,491
  • 11
  • 98
  • 86
Santosh Shinde
  • 6,045
  • 7
  • 44
  • 68