我用的是安卓系统.支持v7.小装置.从this post中学习了如何将汉堡包图标的 colored颜色 更改为白色,但当我打电话时,向上/向后箭头仍然是深色

setDisplayHomeAsUpEnabled(true);

我怎样才能把箭也变成白色呢?

以下是调用setDisplayHomeAsUpEnabled()时工具栏的外观:

在此处输入图像描述

...以下是我风格的相关部分.xml文件:

<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
    <item name="colorPrimary">@color/primary</item>
    <item name="colorPrimaryDark">#194C5F</item>
    <item name="colorAccent">@color/accent</item>
    <item name="drawerArrowStyle">@style/WhiteDrawerIconStyle</item>
</style>

    <style name="WhiteDrawerIconStyle" parent="Widget.AppCompat.DrawerArrowToggle">
        <item name="spinBars">true</item>
        <item name="color">@android:color/white</item>
    </style>

推荐答案

我通过编辑样式解决了这个问题.xml:

<style name="ToolbarColoredBackArrow" parent="AppTheme">
    <item name="android:textColorSecondary">INSERT_COLOR_HERE</item>
</style>

...然后在"活动"的工具栏定义中引用样式:

<LinearLayout
    android:id="@+id/main_parent_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <android.support.v7.widget.Toolbar
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/toolbar"
        app:theme="@style/ToolbarColoredBackArrow"
        app:popupTheme="@style/AppTheme"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:minHeight="?attr/actionBarSize"
        android:background="?attr/colorPrimary"/>

Android相关问答推荐

理解修饰符<;方法>;与修饰符<;方法>;:效果和行为解释(Android开发者Jetpack Compose)

NativeScript在`ns run android`上重复Kotlin类

在Android 14/SDK 34中使用RegisterReceiver的正确方式是什么?

FireBase Android ChildEventListener在被规则拒绝时触发(RTDB)

在Jetpack Compose中实现焦点突出的最佳方式?

可组合:don';t剪辑视图

android回收器查看点击事件无响应

在java android studio项目上安装mapbox

如何使用 Wea​​r OS 上的运行状况服务模拟位置?

为什么@PrimaryKey val id: Int? = null 在创建 Room 实体时有效吗?

将 CircularProgressIndicator 添加到按钮而不增加其高度

延时kotlin中时分秒的使用方法

在 Compose 中停止键盘将顶部应用栏推离屏幕

单击 Jetpack Compose(单选)时,我无法为列表中的单个文本着色

如何在 BasicTextField 中全选焦点

缺少类 com.google.android.datatransport.runtime.ForcedSender

清洁架构中的服务

Jetpack Compose:对角拆分卡片并将内容放入其中

如何使用 Kotlin Coroutines 正确地拥有待处理的操作队列?

jetpack compose 中的可点击指示是什么?