gpt4 book ai didi

java - 如何在 Android 中将 ListView 拉伸(stretch)到全屏

转载 作者:行者123 更新时间:2023-11-29 21:37:47 24 4
gpt4 key购买 nike

假设我有一个垂直布局,顶部有一个按钮,中间有一个 ListView ,底部有一个按钮:

------
BUTTON
LISTVIEW
LISTVIEW
LISTVIEW
------

我想让整个布局可滚动,以便在向下滚动时能够看到完整列表:

------
LISTVIEW
LISTVIEW
LISTVIEW
BUTTON
------

最佳答案

我想我找到了,这里有一个解决方案,无需使用 ScrollView(实际上不需要):

<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<Button android:id="@+id/btn1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"/>

<ListView android:id="@android:id/list1"
android:layout_height="0dip"
android:layout_width="match_parent"
android:layout_weight="1" />

<ListView android:id="@android:id/list2"
android:layout_height="0dip"
android:layout_width="match_parent"
android:layout_weight="1" />

<ListView android:id="@android:id/list3"
android:layout_height="0dip"
android:layout_width="match_parent"
android:layout_weight="1" />

<Button android:id="@+id/btn2"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

</LinearLayout>

关于java - 如何在 Android 中将 ListView 拉伸(stretch)到全屏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17964689/

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