如何把列表项的列表视图底部导航抽屉像四方 [英] 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 =开始的RelativeLayout的。而设置的android:layout_alignParentBottom =真正的属性要设置的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>
这篇关于如何把列表项的列表视图底部导航抽屉像四方的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!