首页 > 解决方案 > android listView裁剪和无法滚动

问题描述

我有一个带有列表视图的片段文件,随着项目数量的增加,它们会填充到屏幕之外,但我无法滚动列表视图以显示隐藏的项目。大多数教程都遵循 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>

标签: androidandroid-listview

解决方案


这里有一个类似的问题,海报表明它一直运行良好,但需要更多元素来滚动。

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

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

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


推荐阅读