为什么我的 ListView 项目重叠而不是滚动?

Why do my ListView items overlap instead of scroll?

据我所知,ListView 应该是可滚动的,无需任何调整,而我的项目只是不断重叠在列表视图边界上。我试过:

但没有任何效果。

这是我的布局

    <?xml version="1.0" encoding="utf-8"?>
<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:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".ListOfChatsActivity">

    <de.hdodenhof.circleimageview.CircleImageView
        android:id="@+id/picture"
        android:layout_width="120dp"
        android:layout_height="120dp"
        app:layout_constraintBottom_toTopOf="@+id/guideline3"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        android:src="@drawable/slika1" />

    <androidx.constraintlayout.widget.Guideline
        android:id="@+id/guideline3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        app:layout_constraintGuide_begin="126dp" />

    <TextView
        android:id="@+id/name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="15dp"
        android:text="@string/name"
        android:textColor="@color/logoBlue"
        android:textSize="22sp"
        app:layout_constraintEnd_toEndOf="@+id/picture"
        app:layout_constraintStart_toStartOf="@+id/picture"
        app:layout_constraintTop_toBottomOf="@+id/picture" />

    <TextView
        android:id="@+id/email"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"
        android:text="@string/email"
        android:textColor="@color/logoBlue"
        android:textSize="18sp"
        app:layout_constraintEnd_toEndOf="@+id/name"
        app:layout_constraintStart_toStartOf="@+id/name"
        app:layout_constraintTop_toBottomOf="@+id/name" />

    <TextView
        android:id="@+id/phone"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:text="@string/phone"
        android:textColor="@color/logoBlue"
        android:textSize="18sp"
        app:layout_constraintEnd_toEndOf="@+id/email"
        app:layout_constraintStart_toStartOf="@+id/email"
        app:layout_constraintTop_toBottomOf="@+id/email" />

    <TextView
        android:id="@+id/tptp"
        android:layout_width="match_parent"
        android:layout_height="41dp"
        android:background="@color/logoBlue"
        android:text="@string/contacts"
        android:textAlignment="center"
        android:textColor="#fff"
        android:textSize="30sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="@+id/guideline3" />

    <ListView
        android:id="@+id/list"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/tptp"
        />

</androidx.constraintlayout.widget.ConstraintLayout>

除了 wrap_content,您应该为您的列表视图设置一个高度,否则如果行太多并且它们可能重叠,您的列表视图将需要使您的根布局可滚动。