在导航视图中显示文本右侧的图标

Display the icon at the right of the text in navigation view

抱歉我的英语不好。 我在某些活动中有一个导航抽屉,我希望每个导航视图项目的图标都放置在该项目文本的右侧,并且整个项目都具有正确的重力。 因为我在我的应用程序中只使用波斯语,所以我不能在我的代码中使用 "supportsRtl",如果我使用,当我将设备语言设置为任何 rtl 语言时它看起来很奇怪。

我想我可以通过为导航视图设置自定义布局来解决这个问题,但我正在寻找一种更简单的方法。这是我的 NavigationView XML 代码:

<android.support.design.widget.NavigationView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:menu="@menu/menu"
    android:layout_gravity="end" />

已编辑:
layoutDirection 是一个很好的答案,但我使用了
drawerLayout.openDrawer(GravityCompat.START);
用于打开导航抽屉。现在,如果设备语言是 rtl 语言,这会使应用程序崩溃。

使 supportsRtl 为 true 并将布局方向设置为导航视图中的 RTL 和其他布局中的 LTR

只需将 android:layoutDirection="rtl" 添加到您的 NavigationView,就像这样:

<android.support.design.widget.NavigationView
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     app:menu="@menu/menu"
     android:layoutDirection="rtl"
     android:layout_gravity="end" />