0

I'm trying to improve my drawer layout, I would make a drawer with header (image and text) and list view, but I can't do it.

this is my layout:

<android.support.v4.widget.DrawerLayout
    android:id="@+id/drawer_layout"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ListView
        android:id="@+id/navdrawer"
        android:layout_width="230dp"
        android:layout_height="wrap_content"
        android:layout_gravity="start"
        android:background="@color/com_facebook_blue"
        android:choiceMode="singleChoice"
        android:divider="@android:color/holo_red_dark"
        android:dividerHeight="2dp">
    </ListView>


    <LinearLayout
    android:id="@+id/bottom_menu"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/sfondo_list_quattro"
    android:orientation="vertical">
    <include
            android:id="@+id/header"
            layout="@layout/listview_header"/>

    <ProgressBar
        android:id="@+id/progressBar"
        android:layout_width="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="300px"
        android:layout_gravity="center"
        android:layout_height="wrap_content"/>

    <ListView
        android:id="@+id/postListView"
        android:layout_width="fill_parent"
        android:paddingTop="50px"
        android:layout_height="0dip"
        android:layout_weight="1"
        android:layout_marginBottom="20dp"
        android:scrollbars="vertical"
        android:divider="@android:color/holo_red_dark"
        android:layout_marginTop="20dp"
        android:background="@drawable/selector"
        android:dividerHeight="3dp">
    </ListView>

</LinearLayout>

</android.support.v4.widget.DrawerLayout>

Is possible to do it whitout fragment?

Thanks guys, have a good day.

KPN24
  • 65
  • 2
  • 9

1 Answers1

0

Easy. Instead of ListView, make a vertical LinearLayout and give that android:layout_gravity="start" for the drawer. Then make your ListView a child of the LinearLayout. Above the ListView you can have another child layout that shows your header.

kris larson
  • 30,387
  • 5
  • 62
  • 74