日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 综合教程 >内容正文

综合教程

ToolBar修改返回按钮图标

發(fā)布時間:2023/12/15 综合教程 35 生活家
生活随笔 收集整理的這篇文章主要介紹了 ToolBar修改返回按钮图标 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

使用Toolbar時,有時因為不同的手機設備,不能使用系統(tǒng)默認的主題樣式或者圖標,必須指定特定的資源,防止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>

在跟節(jié)點加上這幾句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>

修改返回按鈕成功!

使用ToolBar時,需要右上角的菜單按鈕,菜單的文字按鈕顏色也需要修改,在app的主題里修改就可以了,主題中加個:



<item name="android:actionMenuTextColor">#329da3</item>

但只有menu中item設置showAsAction為always的時候才有用

總結

以上是生活随笔為你收集整理的ToolBar修改返回按钮图标的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內容還不錯,歡迎將生活随笔推薦給好友。