gpt4 book ai didi

java - Android ListView 项目顶部对齐

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

我有一个 Android ListView。

<ListView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/myListView"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" >

有时它只包含几项,有时只包含一项。

在这种情况下,这几个项目位于 ListView 的中心。但我希望项目从顶部开始而不是居中。

怎么做?

最佳答案

android:layout_centerVertical="true"
android:layout_centerHorizontal="true"

以上 2 行使您的 ListView 位于其父项的中心。因此您得到的项目位于 ListView 的中心。

你能从你的代码中删除 android:layout_centerVertical="true"并重试吗?

关于java - Android ListView 项目顶部对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33957846/

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