Using following code
-
Another way to achieve this is via setting theme
<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.NavigationViewPadding"
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" />
In your styles
<style name="ThemeToolbar.NavigationViewPadding">
<item name="listPreferredItemPaddingLeft">50dp</item>
</style>
I used @Mahm00d's way, that worked perfectly, but I found another way to solve the problem. It is to add \t
before the String. If the space isn't enough, I can add more.
Because Chinese words are one by one, the length of the item is same.
You can center-align the menu items dynamically using SpannableString
in your activity:
int positionOfMenuItem = 0; //or any other postion
MenuItem item = menu.getItem(positionOfMenuItem);
SpannableString s = new SpannableString(settingsItemTitle);
s.setSpan(new AlignmentSpan.Standard(Alignment.ALIGN_CENTER), 0, s.length(), 0);
item.setTitle(s);