1

I am trying to get a red action bar with white text and I would also like to customize the font of the text, nothing I have tried works, the answer given here Change Background color of the action bar using AppCompat doesn't work. Here is my xml

<resources xmlns:tools="http://schemas.android.com/tools">

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

<item name="android:actionBarStyle">@style/MyActionBar</item>
 </style>

<style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">

    <item name="android:titleTextStyle">@style/ActionBarTitleText</item>
    <item name="android:background">@color/red</item>
    <item name="background">@color/red</item>

</style>

<style name="ActionBarTitleText">
    <item name="android:textColor">@android:color/white</item>


</style>

It seems like everything in here is being ignored, the action bar is black, along with basically everything else on screen, which I really don't want.

Community
  • 1
  • 1
ChristianCuevas
  • 2,672
  • 3
  • 19
  • 24

1 Answers1

0

make two folders under res (values and values-v14) if they are not there. add this code in res (values) folder

<?xml version="1.0" encoding="utf-8"?>
<resources>
   <style name="Theme.Styled" parent="@style/Theme.AppCompat.Light">

    <item name="actionBarStyle">@style/Widget.Styled.ActionBar</item>

</style>

<style name="Widget.Styled.ActionBar" 
    parent="@style/Widget.AppCompat.Light.ActionBar">

 <item name="background">@color/red</item>
 <item name="titleTextStyle">@style/MyTextColor</item>   
</style>
 <style name="MyTextColor"
    parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
    <item name="android:textColor">@color/white</item>
</style>

then this code in res (values-v14) add this code

  <?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Styled" parent="@style/Theme.AppCompat.Light">

    <item name="android:actionBarStyle">@style/Widget.Styled.ActionBar</item>

</style>

<style name="Widget.Styled.ActionBar" 
    parent="@style/Widget.AppCompat.Light.ActionBar">

 <item name="android:background">@color/red</item>
 <item name="android:titleTextStyle">@style/MyTextColor</item>   
</style>
 <style name="MyTextColor"
    parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
    <item name="android:textColor">@color/white</item>
</style>

In your manifest set theme to Theme.Styled

Suwilanji
  • 1
  • 2