gpt4 book ai didi

android - TextView 在 ListView 下面,但是在 parent 的底部,为什么?

转载 作者:行者123 更新时间:2023-11-30 01:30:52 25 4
gpt4 key购买 nike

我在 google 上搜索了很多,并在 stackoverflow 上阅读了更多内容。但是找不到答案。这是我的 ListView :

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
tools:context="k0f.de.americanfootball.AmericanFootballFragment"
tools:showIn="@layout/activity_american_football">>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/league"
android:gravity="center_horizontal"
android:textAppearance="?android:textAppearanceLarge"
android:background="@color/colorPrimaryLight"
android:textColor="@color/colorDarkText"
android:textStyle="bold"
android:text="Deutschland: GFL 1" />
<ListView
android:id="@+id/list"
android:divider="@color/colorListDark"
android:dividerHeight="2dp"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight = "1"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tv_hello"
android:text="Hello World!" />

</LinearLayout>

我将文本 Hello World 替换为来自 fontawesome 的统计图标。

当 ListView 为空时, TextView 是显示的末尾。为什么它不在标题下方的顶部?

这里有两张图片:

Empty ListView Full ListView

最佳答案

TextView 始终位于底部,因为您在 ListView 中使用了 layout_weight="1"。这意味着 ListView 占据了所有遗漏的区域。因此,无论元素是否占据空间,列表都会保留位置,因为它的权重设置为 1。所以 textView 总是被向下推。我认为你对此无能为力。如果您避免重量并使用 wrap_content,则 TextView 可能会在没有足够空间的情况下被推出。

关于android - TextView 在 ListView 下面,但是在 parent 的底部,为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35775628/

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