在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>
通过应用在相对布局中正常运行的方式;