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按鈕中並不起作用


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章