0

I would like to change the color of my settings Tab located on the ActionBar, I have done very extensive research here and in other sources.

My Android version is 4.4.2.

My manifest is declared this way:

    <uses-sdk
    android:minSdkVersion="17"
    android:targetSdkVersion="19" />

Basically I am doing what other sources showed me to:

<style name="AppBaseTheme" parent="android:style/Theme.Holo.Light">
</style>

<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
    <item name="android:panelFullBackground">@drawable/menu_background</item>
</style>

I also have replaced the android:panelFullBackground property for android:panelBackground, android:panelColorBackground and android:panelColorForeground switching from drawable resources to color values for each without results.

Finally I have also tried using ListPopupWindow parent variant:

<style name="AppBaseTheme" parent="android:style/Theme.Holo.Light">
</style>

<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
    <item name="android:popupMenuStyle">@style/PopupMenu</item>
</style>

<style name="PopupMenu" parent="@android:style/Widget.Holo.ListPopupWindow">     
    <item name="android:panelFullBackground">@drawable/menu_background</item>
</style> 

Here I have also switched the android:panelFullBackground property for android:panelColorBackground and android:popupBackground properties mixing them up with @android:color and @drawable resources too but is not working either.

Can you please tell me an effective way to configure this through the styles.xml file?

Thank you very much

CoderRoller
  • 1,239
  • 3
  • 22
  • 39

2 Answers2

2

Maybe you need to use Android Asset studio's ActionBarStyleGenerator to easily handle colors and not going through all the stuff. If you need more customizing on each Tab then you need to get a reference to actionbar using getActionBar()(or getSupportActionBar() in case of support actionbar) and create custom views Programmatically and add them to your actionbar using addTab(...)

M. Erfan Mowlaei
  • 1,376
  • 1
  • 14
  • 25
0

I managed to find the right setting for my styles to accomplish the action bar settings custom color. This post helped as well: How to change the background color of Action Bar's Option Menu in Android 4.2?

The styles go this way:

File styles.xml:

<resources>

<style name="AppBaseTheme" parent="android:style/Theme.Holo.Light">
</style>

<style name="AppTheme" parent="android:Theme.Holo.Light">
    <item name="android:actionBarStyle">@style/MyActionBarTheme</item>        
    <item name="android:popupMenuStyle">@style/PopupMenu</item>
    <item name="android:itemTextAppearance">@style/TextAppearance</item>
</style>

<style name="MyActionBarTheme" parent="@android:Widget.Holo.Light.ActionBar">
    <item name="android:background">#3892D3</item> 
    <item name="android:titleTextStyle">@style/MyActionBarTheme.Text</item>        
</style>    

<!-- 
This style reference did it, you can put a drawable resource or color resource reference there as well. For example: @drawable/menu_dropdown_image or @android:color/white 
-->  
<style name="PopupMenu" parent="@android:Widget.Holo.Light.ListPopupWindow">
    <item name="android:popupBackground">#3892D3</item>        
</style>
<!---->

<style name="MyActionBarTheme.Text" parent="@android:TextAppearance">
    <item name="android:textColor">@android:color/white</item>
    <item name="android:textSize">20sp</item>
</style>    

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

</resources>

Thank you!

Community
  • 1
  • 1
CoderRoller
  • 1,239
  • 3
  • 22
  • 39