如何更改Android材质组件中的工具栏后退按钮图标

问题描述 投票:-1回答:1

我想将默认的向上导航图标(后退按钮图标)更改为我的自定义图标。我不使用抽屉,只是一个简单的工具栏和材料组件

这可能吗?

enter image description here

android android-toolbar androidx material-components-android material-components
1个回答
0
投票

仅使用:

 <androidx.appcompat.widget.Toolbar
        android:theme="@style/MyThemeOverlay_Toolbar"
        />

with:

  <style name="MyThemeOverlay_Toolbar" parent="ThemeOverlay.MaterialComponents.Toolbar.Primary">
    <item name="colorOnPrimary">@color/...</item>
  </style>

enter image description here

它还与MaterialToolbar和默认样式style="@style/Widget.MaterialComponents.Toolbar"一起使用。

而不是如果您正在使用

    <com.google.android.material.appbar.MaterialToolbar
        style="@style/Widget.MaterialComponents.Toolbar.Primary"
        android:theme="@style/MyThemeOverlay_Toolbar"
        ..>

它也会更改标题颜色。

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.