我想在我的应用程序中创建一个导航视图。它是从右边打开的。但是菜单项是ltr方向。 我如何设置他们的rtl。我也必须在清单中设置supportRtl =“ false”。所以解决办法除外。
这是activitymain.xml:
<?xml version="1.0" encoding="utf-8"?>
<include
layout="@layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="right"
android:fitsSystemWindows="true"
android:layoutDirection="rtl"
android:textDirection="anyRtl"
app:headerLayout="@layout/nav_header_main"
app:menu="@menu/activity_main_drawer" />
和activity_main_drawer.xml:
<?xml version="1.0" encoding="utf-8"?>
<group android:checkableBehavior="single"
>
<item
android:id="@+id/nav_home"
android:title="@string/nav_home"
android:icon="@drawable/ic_accessibility"
/>
<item
android:id="@+id/nav_photos"
android:icon="@drawable/ic_accessibility"
android:title="@string/nav_photos"
/>
<item
android:id="@+id/nav_movies"
android:icon="@drawable/ic_accessibility"
android:title="@string/nav_movies" />
<item
android:id="@+id/nav_notifications"
android:icon="@drawable/ic_accessibility"
android:title="@string/nav_notifications" />
<item
android:id="@+id/nav_settings"
android:icon="@drawable/ic_accessibility"
android:title="@string/nav_settings" />
</group>
<item android:title="Other">
<menu>
<item
android:id="@+id/nav_about_us"
android:title="@string/nav_about_us" />
<item
android:id="@+id/nav_privacy_policy"
android:title="@string/privacy_policy" />
</menu>
</item>