java - 更改工具栏溢出图标颜色

标签 java android android-layout android-view android-toolbar

我的 Android 应用中有一个 android.support.v7.widget 工具栏。它的背景颜色是亮橙色,最好看的颜色是白色而不是黑色。

我的默认颜色是黑色而不是白色。由于它会与其他东西冲突,因此几乎不可能覆盖。 我无法将主要文本颜色更改为白色!

我已设法更改标题颜色。 我现在正在寻找的是如何将操作按钮的颜色也更改为白色。

enter image description here

我的代码:

主要 Activity :

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".UI.activities.MainActivity">

<android.support.v7.widget.Toolbar
    android:id="@+id/r2_toolbar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:background="?attr/colorPrimary"
    android:elevation="4dp"
    app:titleTextColor="@color/primary_text_material_light"
    app:subtitleTextColor="@color/primary_text_material_light"
    android:theme="@style/R2Theme.Toolbar"/>

<fragment android:name="com.r2retail.r2retailapp.UI.fragments.SetupFragment"
    android:layout_below="@+id/r2_toolbar"
    android:id="@+id/list"
    android:layout_weight="1"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />


</RelativeLayout>

菜单栏:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<item android:id="@+id/about"
    android:icon="@drawable/ic_menu"
    android:title="About"
    app:showAsAction="never"/>

</menu>

样式:

<resources>

<style name="R2Theme" parent="Theme.AppCompat.Light.NoActionBar">=
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorPrimary</item>
    <item name="android:textColorPrimary">@color/secondary_text_material_dark</item>
    <item name="android:textColorSecondaryInverse">@color/primary_text_material_light</item>
</style>

<style name="R2Theme.Toolbar" parent="R2Theme">
    <item name="actionMenuTextColor">@color/primary_text_material_light</item>
</style>

</resources>

最佳答案

在样式方面:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    ...
    <item name="actionOverflowButtonStyle">@style/MyOverflowButtonStyle</item>
</style>

<style name="MyOverflowButtonStyle" parent="Widget.AppCompat.ActionButton.Overflow">
    <item name="android:tint">#62ff00</item>
</style>

结果:

enter image description here

关于java - 更改工具栏溢出图标颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43537958/

相关文章:

java - 如何解决Jdk9/java-9中module-info.java编译错误

java - Spring boot Web服务/微服务和调度

java - 如何手动查找android文件的文件路径?

java - 项目再次启动(更新)后如何保护我的数据库值?

android - 如何在android中首次启动时将预安装应用程序安装到/data/app

android - 我如何开发 Android 应用程序以在不同的屏幕分辨率下工作

android - 如何从gradle中的sdk中排除jar

android - GetPackageInfo 导致 DeadObjectException

java - 以编程方式将 TextView 放置在相对布局中的彼此下方

Android为按钮添加边框而不丢失 Material 主题(使用drawable)