How to put list items at the bottom of list view in Navigation Drawer like Foursquare

前端 未结 2 693
清歌不尽
清歌不尽 2020-12-03 08:04

I got a list view for navigation drawer, how can I put list item like \"Add Friends\", \"Settings\" align at the bottom of the list view.

相关标签:
2条回答
  • 2020-12-03 08:19

    Jay Donga was really helpful, but I had to change two methods to insert a footer in my DrawerLayout.

    // WITHOUT FOOTER VIEW
    mDrawerLayout.isDrawerOpen(mDrawerList)
    mDrawerLayout.closeDrawer(mDrawerList)
    
    // WITH FOOTER VIEW
    mDrawerContent = (RelativeLayout) findViewById(R.id.relative_layout);
    mDrawerLayout.isDrawerOpen(mDrawerContent)
    mDrawerLayout.closeDrawer(mDrawerContent)
    
    0 讨论(0)
  • 2020-12-03 08:27

    You can put the ListView inside a RelativeLayout and assign android:layout_gravity="start" to the RelativeLayout. And set android:layout_alignParentBottom="true" property to the view you want to set to bottom of ListView.

    This may help you.

    <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" >
    
    <FrameLayout
        android:id="@+id/content_frame"...../>
    
    <RelativeLayout
        android:id="@+id/relative_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="start" >
    
        <ListView
            android:id="@+id/left_drawer"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="#111"
            android:choiceMode="singleChoice"
            android:divider="@android:color/transparent"
            android:dividerHeight="0dp" />
    
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true" >
    
            <TextView
                android:id="@+id/text_view1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Add Friends" />
    
            <TextView
                android:id="@+id/text_view2"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Settings" />
        </RelativeLayout>
    </RelativeLayout>
    
    </android.support.v4.widget.DrawerLayout>
    
    0 讨论(0)
提交回复
热议问题