user782104
user782104

Reputation: 13555

How to add a view above drawer layout?

http://developer.android.com/design/patterns/navigation-drawer.html

I am working on navigation-drawer. The code suggested that I use a navigation drawer like this:

<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <!-- The main content view -->
    <FrameLayout
        android:id="@+id/content_frame"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
    <!-- The navigation drawer -->
    <ListView android:id="@+id/left_drawer"
        android:layout_width="240dp"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:choiceMode="singleChoice"
        android:divider="@android:color/transparent"
        android:dividerHeight="0dp"
        android:background="#111"/>
</android.support.v4.widget.DrawerLayout>

The framelayout would store the fragment and the left_drawer is the left menu, the problem is , I would like to add a view between left_drawer and framelayout, which is

left_drawer on top of my view , my view on top of framelayout. How to implement such layout? or I need to add my view to every fragment ?

Thanks

Updated:

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

    <!--
         As the main content view, the view below consumes the entire
         space available using match_parent in both dimensions.
    -->

    <FrameLayout
        android:id="@+id/content_frame"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <!--
         android:layout_gravity="start" tells DrawerLayout to treat
         this as a sliding drawer on the left side for left-to-right
         languages and on the right side for right-to-left languages.
         The drawer is given a fixed width in dp and extends the full height of
         the container. A solid background is used for contrast
         with the content view.
    -->

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:orientation="horizontal" >

        <TextView
            android:id="@+id/bottomMenu1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="@color/bottom_menu_unchecked"
            android:gravity="center"
            android:text="@string/bottom_menu_1"
            android:textColor="#ffffff"
            android:textSize="20sp" />

        <TextView
            android:id="@+id/bottomMenu2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="@color/bottom_menu_unchecked"
            android:gravity="center"
            android:text="@string/bottom_menu_2"
            android:textColor="#ffffff"
            android:textSize="20sp" />

        <TextView
            android:id="@+id/bottomMenu3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="@color/bottom_menu_unchecked"
            android:gravity="center"
            android:text="@string/bottom_menu_3"
            android:textColor="#ffffff"
            android:textSize="20sp" />

        <TextView
            android:id="@+id/bottomMenu4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="@color/bottom_menu_unchecked"
            android:gravity="center"
            android:text="@string/bottom_menu_4"
            android:textColor="#ffffff"
            android:textSize="20sp" />
    </LinearLayout>

    <ListView
        android:id="@+id/left_drawer"
        android:layout_width="240dp"
        android:layout_height="0dip"
        android:layout_gravity="start"
        android:layout_weight="1"
        android:background="#111"
        android:choiceMode="singleChoice"
        android:divider="@android:color/transparent"
        android:dividerHeight="0dp" />

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

Upvotes: 0

Views: 2862

Answers (1)

M D
M D

Reputation: 47817

Put a View above a ListView, and wrap it inside a vertical LinearLayout . Give to your ListView android:layout_weight="1" and android:layout_height="0dip"

Upvotes: 4

Related Questions