如何将列表项放在导航抽屉中的列表视图底部,如 Foursquare [英] How to put list items at the bottom of list view in Navigation Drawer like Foursquare
问题描述
我有一个导航抽屉的列表视图,如何将添加好友"、设置"等列表项对齐到列表视图的底部.
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.
更新1
我在页脚视图中添加了一个设置视图.
Update 1
I add a setting view to the footer view.
View settingView = getLayoutInflater().inflate(R.layout.drawer_list_item, null);
TextView textView = (TextView)settingView.findViewById(R.id.drawer_list_item_text_view);
textView.setText("Settings");
drawerListView.addFooterView(settingView);
设置项成功出现在列表视图的最后一项.但是我怎样才能让它粘在底部并对齐呢?谢谢.
The settings item appear at the last one in the list view successfully. But how can I make it to stick and align at the bottom? Thanks.
推荐答案
您可以将 ListView
放在 RelativeLayout
中并分配 android:layout_gravity="start"
到 RelativeLayout
.并将 android:layout_alignParentBottom="true"
属性设置为要设置为 ListView
底部的视图.
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
.
这可能对您有所帮助.
<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>
这篇关于如何将列表项放在导航抽屉中的列表视图底部,如 Foursquare的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!