【发布时间】:2020-03-18 11:18:19
【问题描述】:
我对列表视图的设计有疑问。
当有几个项目时,我想减少列表,但如果我将包装内容放在屏幕中间。
我该怎么办?
我的列表视图:
<ListView
android:id="@+id/listView_location"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_below="@id/searchView_location"
android:layout_marginBottom="8dp"
app:layout_constrainedHeight="true"
app:layout_constraintBottom_toTopOf="@+id/searchView_location"
app:layout_constraintEnd_toEndOf="@+id/searchView_location"
app:layout_constraintStart_toStartOf="@+id/searchView_location"
app:layout_constraintTop_toTopOf="parent"/>
约束布局
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/root_layout_search"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusableInTouchMode="true">
【问题讨论】:
-
"ListView" 正在占用其父级 "constraintlayout" 的高度,请分享 listview 的父级布局
-
将其高度更改为 wrap_content 即 contraintlayout
-
@xlu 谢谢,但约束布局上的 android:layout_height="wrap_content" 也有同样的问题
标签: android android-layout listview