android - 如何更改导航架构组件中的向上按钮颜色
问题描述
这是我的样式代码
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.DayNight.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/lightGrey</item>
<item name="colorPrimaryDark">@color/black</item>
<item name="colorAccent">@color/grey</item>
<item name="colorControlNormal">@color/lightGrey</item>
</style>
<style name="TextAppearance.AppCompat.Widget.ActionBar.Title"
parent="@android:style/TextAppearance">
<item name="android:textColor">@color/mediumBlack</item>
</style>
这是导航UI代码
val myNavController = this.findNavController(R.id.myNavHostFragment)
NavigationUI.setupActionBarWithNavController(this, myNavController)
文本更改颜色在样式名称“TextAppearance.AppCompat.Widget.ActionBar.Title”下效果很好,但我想更改 upButton 的颜色。它默认显示为白色,我想将其更改为黑色。
解决方案
在您的应用主题中添加actionBarTheme
属性:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
.....
<item name="actionBarTheme">@style/MyActionBarTheme</item>
</style>
和:
<style name="MyActionBarTheme" parent="ThemeOverlay.AppCompat.ActionBar">
<item name="colorControlNormal">@color/....</item>
</style>
推荐阅读
- maven - Maven 安装期间有关无效 maven-metadata-nexus.xml 的警告
- laravel - Bluehost 共享主机:无法连接到 gmail smtp
- swift - Swift:'if'语句,a等于b或c
- java - Recycleview 项目增值
- mysql - 在MySql中如何设计两个具有相同列但具有不同关系的表
- lua - 返回更多函数的函数创建无限循环
- python - 读取 .csv 的内容并使用 python 将其写入另一个 .csv 文件
- mysql - MySQL 在两个 ISO 格式的日期之间进行选择
- c++ - 带有 libc++ 异常的 Clang
- python - Python中普通变量访问有什么用?