簡體   English   中英

如何在抽屜布局上方添加視圖?

[英]How to add a view above drawer layout?

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

我正在研究導航抽屜。 該代碼建議我使用如下所示的導航抽屜:

<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>

framelayout將存儲片段,而left_drawer是左側菜單,問題是,我想在left_drawer和framelayout之間添加一個視圖

left_drawer on top of my view , my view on top of framelayout 如何實現這樣的布局? 還是我需要將視圖添加到每個片段?

謝謝

更新:

<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>

將View放在ListView上方,並將其包裝在垂直的LinearLayout中。 給您的ListView android:layout_weight =“ 1”和android:layout_height =“ 0dip”

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM