android listView 裁剪且无法滚动

android listView clipping and unable to scroll

我有一个带有列表视图的片段文件,随着项目数量的增加,它们会填充到屏幕之外,但我无法滚动列表视图来调出隐藏的项目。大多数教程都遵循 LinearLayout 等,但我想留在现代约束布局模式中。

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ListView
        android:id="@+id/userList"
        android:layout_width="409dp"
        android:layout_height="729dp"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</android.support.constraint.ConstraintLayout>

有一个类似的问题 HERE 发帖者表示它一直都运行良好,但需要更多元素才能滚动。

如果不是这种情况,请尝试在您的 ListView 中进行设置

android:layout_height="0dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"

我没有测试过,但有些人报告成功了,所以试一试吧。