Skip to content Skip to sidebar Skip to footer

Right To Left Menu Items Android In Navigationview

im beginer of android. i design a navigation drawer like this: as you see all items in menu are on the right Except 'SubHeader'. how can i move 'SubHeader' item to the right of th

Solution 1:

Try adding these attributes to NavigationView in your layout file.

android:layoutDirection="rtl"android:textDirection="rtl"

If no other way. You should use custom layout

example:

<android.support.design.widget.NavigationView
  android:layoutDirection="rtl"
  android:id="@+id/navigation_view"
  android:layout_width="wrap_content"
  android:layout_height="match_parent"
  android:layout_gravity="right"
  android:fitsSystemWindows="true"
  app:headerLayout="@layout/nav_header_main"
  app:menu="@menu/activity_main_drawer>
 <LinearLayout>
 // code xml here
 </LinearLayout>
 <android.support.design.widget.NavigationView/>

Solution 2:

try this make your menu gravity="right" of your menu item

<menuxmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"android:gravity="end"android:layoutDirection="rtl"android:layout_gravity="end"><groupandroid:checkableBehavior="single"android:layout_gravity="end"android:gravity="end"><itemandroid:id="@+id/nav_1"android:icon="@drawable/abc"android:gravity="end"android:layout_gravity="end"android:title="menu title"/></group></menu>

and make your navigation view like this

<android.support.design.widget.NavigationView
      android:layoutDirection="rtl"
      android:id="@+id/navigation_view"
      android:layout_width="wrap_content"
      android:layout_height="match_parent"
      android:layout_gravity="right"
      android:fitsSystemWindows="true"
      app:headerLayout="@layout/nav_header_main"
      app:menu="@menu/activity_main_drawer" />

Post a Comment for "Right To Left Menu Items Android In Navigationview"