Main activity layout (removed the irrelevant elements):
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/black"
<RelativeLayout
android:id="@+id/layout_relative_in_drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/black" >
// some more elements ...
</RelativeLayout>
<ListView
android:id="@+id/drawer_main"
android:layout_width="120dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#80000000"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="10dp" />
</android.support.v4.widget.DrawerLayout>
drawer_item.xml:
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawerItemTextView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:layout_gravity="center"
android:textColor="@android:color/white" >
</TextView>
The list items are aligned to the center horizontally now, but not vertically.
What should i modify to center them vertically?
Change your drawer item to this:
then try, it is working for me.
drawer_item.xml:
Probably you should change the gravity of items to: