Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I change the Action Bar Overflow button color

Tags:

android

First off I have read Change color of the overflow button on action bar but I'm not able to get it to work.

I just want to have a simple theme: Action bar background blue and the buttons and text white. For the list views that I have I want them to be the inverse: white background and blue text. If there is a simple way to achieve this please let me know. I have tried setting text color using a style but I cannot get the text and the buttons to be different colors so I tried setting the overflow drawable and for testing purposes I made the dots red but don't see any effect.

    <!-- Application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light">
    <item name="actionBarStyle">@style/ActionBarStyle</item>
</style>

<style name="ActionBarStyle" parent="Widget.AppCompat.ActionBar">
    <item name="background">@color/background_blue</item>
    <item name="titleTextStyle">@style/AppTheme.ActionBar.Title</item>
    <item name="actionOverflowButtonStyle">@style/AppTheme.ActionButton.Overflow</item>
</style>

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

<style name="AppTheme.ActionButton.Overflow"  parent="@style/Widget.AppCompat.ActionButton.Overflow">
    <item name="android:src">@drawable/abc_ic_menu_overflow_button</item>
</style>

The overflow button that I'm using for testing The overflow button that I'm using for testing

While what I see

What I see

which clearly is not using the red buttons.

I was able to use the android:textColorPrimary attribute but that has undesirable side effects.

    <style name="AppTheme" parent="Theme.AppCompat.Light">
    <item name="android:textColorPrimary">@color/white</item>
    <item name="actionBarStyle">@style/ActionBarStyle</item>
</style>

<style name="ActionBarStyle" parent="Widget.AppCompat.ActionBar">
    <item name="background">@color/background_blue</item>
    <item name="titleTextStyle">@style/AppTheme.ActionBar.Title</item>
</style>

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

enter image description here

but then since I want a white background for my lists I end up not being able to see some text since the text and background are both white.

Thanks!

like image 761
bitrock Avatar asked Mar 11 '16 05:03

bitrock


People also ask

Which attribute is used to set the color of the icon of the overflow menu?

This can be achieved by setting the android:textColorSecondary theme attribute.

How do I change the color of my taskbar icons on Android?

Also, if you want to change the toolbar text color: Spannable spannableString = new SpannableString(t); spannableString. setSpan(new ForegroundColorSpan(Color. rgb(50, 50, 50)), 0, t.

Where is the action overflow menu icon?

The right-hand side of the action bar shows the actions. The action buttons (3) show the most important actions of your app. Actions that do not fit in the action bar are moved to the action overflow, and an overflow icon appears on the right.


1 Answers

I found another way to do it which does not require replacing the image!

<style name="AppTheme" parent="Theme.AppCompat.Light">
    <item name="actionBarTheme">@style/AppTheme.ActionBarTheme</item> <!-- used for the back arrow on the action bar -->
</style>

<style name="AppTheme.ActionBarTheme" parent="@style/ThemeOverlay.AppCompat.ActionBar">
    <!-- THIS is where you can color the arrow and the overflow button! -->
    <item name="colorControlNormal">@color/splash_title</item> <!-- sets the color for the back arrow -->
    <item name="actionOverflowButtonStyle">@style/actionOverflowButtonStyle</item> <!-- sets the style for the overflow button -->
</style>

<!-- This style is where you define the tint color of your overflow menu button -->
<style name="actionOverflowButtonStyle" parent="@style/Widget.AppCompat.ActionButton.Overflow">
    <item name="android:tint">@color/white</item>
</style>
like image 153
bitrock Avatar answered Oct 01 '22 18:10

bitrock