gpt4 book ai didi

android - 如何在 Foursquare 等抽屉导航中将列表项放在 ListView 的底部

转载 作者:IT老高 更新时间:2023-10-28 23:10:31 25 4
gpt4 key购买 nike

我有一个用于抽屉导航的 ListView ,如何将“添加 friend ”、“设置”等列表项放在 ListView 的底部。

enter image description here

更新 1
我在页脚 View 中添加了一个设置 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);

设置项成功出现在 ListView 的最后一项。但是我怎样才能让它粘在底部并对齐呢?谢谢。

最佳答案

您可以将 ListView 放入 RelativeLayout 并将 android:layout_gravity="start" 分配给 RelativeLayout。并将 android:layout_alignParentBottom="true" 属性设置为要设置为 ListView 底部的 View 。

这可能会对你有所帮助。

<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>

关于android - 如何在 Foursquare 等抽屉导航中将列表项放在 ListView 的底部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19156476/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com