我的应用中有2个导航抽屉。如何更改右侧导航抽屉的图标?我看到的所有链接都在谈论一个导航抽屉盒并使用ActionBarToggle解决。
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<include
layout="@layout/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.NavigationView
android:id="@+id/nav_viewLeft"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"
app:headerLayout="@layout/nav_header_main"
app:menu="@menu/activity_main_drawer_left" />
<android.support.design.widget.NavigationView
android:id="@+id/nav_viewRight"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="end"
android:fitsSystemWindows="true"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"
app:menu="@menu/activity_main_drawer_right" />
</android.support.v4.widget.DrawerLayout>
答案 0 :(得分:2)
您只能在工具栏的左侧显示导航图标。可能的解决方案是使用菜单来包含https://material.io/icons/
中的导航抽屉图标<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:myapp="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:id="@+id/search" android:icon="@drawable/ic_search_white_24dp"
android:title="@string/search"
app:showAsAction="always"
/>
<item
android:id="@+id/btnMyMenu"
android:icon="@drawable/ic_menu_white_24dp"
android:title="Right Side Menu"
myapp:showAsAction="always"/>
</menu>
点击btnMyMenu使用
打开抽屉mDrawerLayout.openDrawer(Gravity.RIGHT);
然后隐藏并相应地显示该菜单