2015-01-06 46 views
0

我有一個導航抽屜列表,其中我已經放置了某些項目,如配置文件,插入等等。每個項目對應一個片段。現在我不想把註銷按鈕,但我想把它放在導航抽屜列表的下面。因爲它只是做註銷用戶的工作,並且我的應用程序不需要用戶交互。我希望該用戶單擊註銷和他/她的日誌所以我想把註銷按鈕分開放在列表下面。 XML:如何在導航抽屜列表的末尾添加註銷按鈕

<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" 
android:background="@android:color/white"> 
<!-- Framelayout to display Fragments --> 
<FrameLayout 
    android:id="@+id/frame_container" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" /> 
<LinearLayout 
android:id="@+id/drawerLL1" 
android:layout_width="40dp" 
android:layout_height="200dp" 
android:background="@color/list_background" 

> 
<!-- Listview to display slider menu --> 
<ListView 
    android:id="@+id/list_slidermenu" 
    android:layout_width="240dp" 
    android:layout_height="match_parent" 
    android:layout_gravity="start" 
    android:choiceMode="singleChoice" 
    android:divider="@color/list_divider" 
    android:dividerHeight="1dp"   
    android:listSelector="@drawable/list_selector" 
    android:background="@color/list_background" 
    /> 
<Button 
    android:id="@+id/drawerButton1" 
    android:layout_width="40dp" 
    android:height="200dp" 
    /> 

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

所以第二個孩子,把一個有。抽屜不一定是一個ListView,或RecyclerView,或任何你在那裏。它可以是一個垂直的LinearLayout,其頂部有一個ListView,下面是一個Button。 –

+0

如何以編程方式連接它們。請給我提供例子嗎? – user2866916

回答

2

您需要添加ListView和按鈕在LinearLayout中並添加此佈局的DrawerLayout

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


    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" 
     android:id="@+id/llDisplay"> 

    </LinearLayout> 


    <LinearLayout 
     android:layout_width="280dp" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     android:orientation="vertical"> 

    <ListView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"></ListView> 

    <Button 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" /> 
    </LinearLayout> 

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

我試過這個,但它不允許我設置按鈕 – user2866916

+0

的寬度,高度和文本屬性,因爲您正在使用支持庫的小部件,所有屬性在下拉菜單中都不可見。您無論如何嘗試添加它們。他們將工作 – Simar

+1

正確.. android:layout_gravity =「開始」 – Simar