gpt4 book ai didi

android - 在两个元素之间添加一个 listView

转载 作者:行者123 更新时间:2023-11-29 17:51:22 26 4
gpt4 key购买 nike

我想在顶部和底部按钮之间添加一个 listView。我不希望它有一个固定的大小,所以我试着这样设置:

<Button 
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true" />

<ListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@+id/button1" />

<Button
android:id="@+id/button2
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" />

但是这样设置布局文件时,listview当然是在第一个button的下面,但是从那里向下一直到屏幕的button,不会停在button2的上面。--> listview 与 button2 重叠。

如何将 ListView 放在这两个按钮之间?

最佳答案

android:layout_above="@+id/button2" 属性添加到 ListView 如下...这将保留 ListViewbutton2 之上。

<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true" />

<ListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@+id/button1"
android:layout_above="@+id/button2" />

<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" />

关于android - 在两个元素之间添加一个 listView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22614455/

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