我得到了一个列表视图的导航抽屉,我怎么能把列表项目,如“添加朋友”,“设置”对齐在列表视图的底部。
更新1
我在页脚视图中添加了一个设置视图。
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);
设置项成功出现在列表视图的最后一项。但是我怎样才能让它在底部粘合并对齐?谢谢。
发布于 2013-10-09 01:50:20
您可以将ListView
放在RelativeLayout
中,并将android:layout_gravity="start"
分配给RelativeLayout
。并将android:layout_alignParentBottom="true"
属性设置为要设置为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>
发布于 2014-01-26 02:40:40
Jay Donga真的很有帮助,但我不得不改变两种方法来在我的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)
https://stackoverflow.com/questions/19156476
复制相似问题