Can't Center Navigation Drawer Items Vertically
Main activity layout (removed the irrelevant elements): Copy
then try, it is working for me.
Solution 2:
<RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent" ><android.support.v4.widget.DrawerLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:id="@+id/drawer_layout"android:layout_width="match_parent"android:layout_height="match_parent"android:background="#ffffff" ><FrameLayoutandroid:id="@+id/content_frame"android:layout_width="match_parent"android:layout_height="wrap_content"android:background="#eeeeee" ></FrameLayout><ListViewandroid:id="@+id/left_drawer"android:layout_width="240dp"android:layout_height="match_parent"android:layout_gravity="start"android:background="#333333"android:choiceMode="singleChoice"android:divider="@android:color/darker_gray"android:dividerHeight="1dp" /></android.support.v4.widget.DrawerLayout>
<?xml version="1.0" encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="50dp"android:orientation="horizontal" ><TextViewandroid:id="@+id/text"android:layout_width="match_parent"android:layout_height="match_parent"android:gravity="center|left"android:padding="5dp"android:text="Medium Text"android:textColor="#FB9200" /></LinearLayout>
Solution 3:
drawer_item.xml:
<RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="wrap_content" ><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerInParent="true"android:text="a" /></RelativeLayout>
Solution 4:
Probably you should change the gravity of items to:
android:gravity="center|center_vertical"
Post a Comment for "Can't Center Navigation Drawer Items Vertically"