3

as the title described ; I need to set gravity for these items down below is the picture ; ( i read Can't center Navigation Drawer items vertically but it didnt work )

my navigation drawer code :

    <android.support.design.widget.NavigationView
    android:id="@+id/nav_view"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:fitsSystemWindows="true"
    app:headerLayout="@layout/activity_nav_header_main"
    app:menu="@menu/activity_main_drawer"
    />

enter image description here

Community
  • 1
  • 1
Flava
  • 77
  • 1
  • 8
  • You can create style for it. For reference you can check this - http://stackoverflow.com/a/33140661/2128166 – Wasim K. Memon Feb 11 '16 at 18:54
  • http://stackoverflow.com/a/34329756/1462770 – Amir Feb 11 '16 at 18:57
  • 1
    i used but the items text is still on the right , i need it to appear from left – Flava Feb 11 '16 at 19:06

1 Answers1

1

This can be achieved by setting theme to navigation menu

 <android.support.design.widget.NavigationView
    android:id="@+id/nav_view"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:fitsSystemWindows="true"
    android:theme="@style/ThemeToolbar.NavigationView"
    app:itemTextColor="@color/inverse_color"
    app:itemIconTint="@color/inverse_color"
    app:itemBackground="@drawable/selector_navigation"
    app:headerLayout="@layout/activity_home_nav_header"
    app:menu="@menu/activity_home_drawer" />

Create a style as follows

<style name="ThemeToolbar.NavigationView">
    <item name="android:listDivider">@color/inverse_color</item>
    <item name="android:textColorSecondary">@color/inverse_color</item>
    <item name="listPreferredItemPaddingRight">50dp</item>
</style>
turbandroid
  • 2,296
  • 22
  • 30