ToolBar修改系统后退键图标, 设置menu字体颜色大小

 

更换ToolBar系统后退键

ToolBar下添加下面3行

xmlns:app="http://schemas.android.com/apk/res-auto"
app:navigationIcon="@mipmap/ic_back"
android:navigationIcon="@mipmap/ic_back"


ToolBar修改menu item的字体颜色


在你的样式文件中定义如下style

[html]  view plain  copy
  1. <style name="AppTheme.ActionBar" parent="Theme.AppCompat.Light.DarkActionBar">  
  2.          ...  
  3.     <item name="actionMenuTextColor">@color/text_color</item>  
  4.          ...  
  5. </style>  
然后在你的ToolBar中引用上述style,就像这样
[html]  view plain  copy
  1. <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"  
  2.    xmlns:app="http://schemas.android.com/apk/res-auto"  
  3.    android:id="@+id/main_toolbar"  
  4.    android:layout_width="match_parent"  
  5.    android:layout_height="?attr/actionBarSize"  
  6.    android:background="?attr/colorPrimary"  
  7.    android:layout_gravity="top"  
  8.    app:popupTheme="@style/ThemeOverlay.AppCompat.Light"  
  9.    android:theme="@style/AppTheme.ActionBar"/>  

最后,该大神再次提示:Android:theme="@style/AppTheme.ActionBar", don't forget this line in your toolbar

靠谱


发现一个问题,在之后修改menu字体大小的时候,又出现了不管用的现象,仔细对比发现如下不同

[html]  view plain  copy
  1. <!-- 我这定义name时加上了android:,结果不管用 -->  
  2. <item name="android:actionMenuTextAppearance">@style/WhiteMenuTextAppearance</item>  
  3. <!-- 之后去掉android:,管用了 -->  
  4. <item name="actionMenuTextAppearance">@style/WhiteMenuTextAppearance</item>  
 

哪位大神能告知下,加与不加的区别在哪呢

发现第二个问题,更改字体颜色和大小后,之有显示在ToolBar中才起作用,设置app:showAsAction="never"收在more按钮中并不起作用


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值