如何更改操作栏溢出按钮的颜色 [英] How do I change the Action Bar Overflow button color

查看:169
本文介绍了如何更改操作栏溢出按钮的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我已阅读在操作时更改溢出按钮的颜色吧但是 我无法使其正常工作.

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

我所看到的

显然没有使用红色按钮.

which clearly is not using the red buttons.

我能够使用android:textColorPrimary属性,但是有不良的副作用.

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>

但是由于我希望列表的背景为白色,所以最终我无法看到一些文本,因为文本和背景都是白色的.

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.

谢谢!

推荐答案

我发现了另一种不需要替换图像的方法!

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>

这篇关于如何更改操作栏溢出按钮的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆