gpt4 book ai didi

ListView 的 Android 布局,后跟屏幕底部的非滚动文本条

转载 作者:搜寻专家 更新时间:2023-11-01 07:41:20 25 4
gpt4 key购买 nike

我在设置 Android 布局时遇到问题。

喜欢的是一个可滚动的 ListView,后跟一小段不会滚动并始终位于屏幕底部的文本 (TextView)。

它看起来像这样:

ListViewItem1

ListViewItem2

ListViewItem3

此处的文本栏(无论 ListView 的滚动状态如何,始终显示)

我已经尝试了很多不同的变体,但没有一个显示静态文本

关于我哪里出错了有什么想法吗?

谢谢!

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<ListView android:id="@+id/list2" android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
<TextView android:layout_width="fill_parent"
android:layout_height="50dip" android:text="Bar of text that always stays at the bottom of the screen" />
</LinearLayout>

最佳答案

使用 RelativeLayout。使用 android:layout_alignParentBottom="true"TextView 锚定到底部。让 ListView 填充剩余部分。

或者,使用单个 LinearLayout,将 ListViewandroid:layout_height 设置为 0pxandroid:layout_weight1ListView 之后的 TextView 作为 LinearLayout 的子级>.

关于ListView 的 Android 布局,后跟屏幕底部的非滚动文本条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1841209/

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