android - 如何在工具栏中将箭头颜色设为白色
问题描述
我是新开发人员。我只是在工具栏中添加了返回箭头,但它是黑色的。我怎么让它变白。下面是我的代码:
爪哇
setSupportActionBar(newToolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
文件
<android.support.v7.widget.Toolbar
android:id="@+id/newToolBarId"
android:background="@color/colorPrimary"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</android.support.v7.widget.Toolbar>
解决方案
我通过编辑styles.xml解决了它:
<style name="ToolbarColoredBackArrow" parent="AppTheme">
<item name="android:textColorSecondary">#ffffff</item>
...然后在活动的工具栏定义中引用样式:
<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"/>
推荐阅读
- c# - 将枚举显示为键值对 JSON
- tensorflow - Tensorflow 2 - 如何有条件地直接在 tf.Variable 中更新值
- python - 通过循环比较列表中的嵌套字典值?
- ruby - 本地mac机器上的jekyll安装失败
- c# - csproj文件中`NativeLibs`元素的用途是什么
- node.js - 为什么我的 dockerized Node.js 应用程序看到 localhost?
- javascript - 如何将多张图片上传到 Twitter?
- javascript - 关闭选项卡或浏览器时注销用户,但在 React Js 中刷新浏览器时不应注销
- webrtc - 了解 webRTC 比特率约束
- java - Spring JPA多对多关系导致内容重复