ToolBar修改返回按钮图标
使用Toolbar时,有时因为不同的手机设备,不能使用系统默认的主题样式或者图标,必须指定特定的资源,防止APP在不同设备上的效果不一样!
我在使用Toolbar时,把这个布局作为一个公共的了,所以修改起来比较容易,下面是该Toolbar的布局文件:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:id="@+id/toolbar"
android:layout_height="wrap_content"
android:background="?attr/day_actionbar_bg">
<TextView
android:id="@+id/tv_title"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:textSize="@dimen/actionbar_txtSize"
android:textColor="?attr/common_login_txtbg"/>
</android.support.v7.widget.Toolbar>
在跟节点加上这几句i就可以了:
xmlns:app="http://schemas.android.com/apk/res-auto"
app:navigationIcon="@drawable/navigationIcon"
android:navigationIcon="@drawable/navigationIcon"
就可以修改返回按钮的图标样式了,
完整的布局代码是这样的:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:id="@+id/toolbar"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:navigationIcon="@drawable/navigationIcon"
android:navigationIcon="@drawable/navigationIcon"
android:layout_height="wrap_content"
android:background="?attr/day_actionbar_bg">
<TextView
android:id="@+id/tv_title"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:textSize="@dimen/actionbar_txtSize"
android:textColor="?attr/common_login_txtbg"/>
</android.support.v7.widget.Toolbar>
修改返回按钮成功!
Menu菜单文字的颜色修改:
使用ToolBar时,需要右上角的菜单按钮,菜单的文字按钮颜色也需要修改,在app的主题里修改就可以了,主题中加个:
<item name="android:actionMenuTextColor">#329da3</item>
但只有menu中item设置showAsAction为always的时候才有用
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
2016-03-22 Swift Explore - 关于 Swift 中的 isEqual 的一点探索
2016-03-22 iOS-BLE蓝牙开发持续更新