Android垂直RecyclerView在ConstraintLayout内部的高度变为0;

时间:2019-11-17 08:18:20

标签: android android-recyclerview android-constraintlayout androidx

在android studio的预览中,该应用很好,但在运行时高度为零;这是布局的xml:

<?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:id="@+id/filemaneger_id"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#f6f6f6"
    android:focusable="true"
    android:layoutDirection="ltr">

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/recycv"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:background="#ffffff"
        android:scrollbars="vertical"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

通过应用在相对布局中正常运行的方式;

0 个答案:

没有答案