我在约束布局中有一个回收站视图,该视图显示了来自数据库的数据。我希望最大高度为500dp,但问题是,当它超过该大小时,它将从视图底部切出一部分。我不知道会出什么问题。
这里是RecyclerView的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:layout_width="fill_parent"
android:layout_height="wrap_content"
android:maxHeight="500dp"
tools:context=".histDialog">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:padding="3dp"
app:layout_constrainedHeight="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
[recyclerview显示在一个样式为对话框的活动中。
我已经尝试过所有可能想到的事情,但是我无法使其正常工作。
替换为:
android:layout_height="wrap_content"
android:maxHeight="500dp"
with:
android:layout_height="wrap_content"
app:layout_constraintHeight_max="500dp"
app:layout_constrainedHeight="true"
在您的ConstraintLayout声明中。