【发布时间】:2021-02-27 15:08:30
【问题描述】:
我有一个 recyclerview 并且我正在使用约束布局。现在我想将高度用作 wrap_content 但想以百分比设置最大高度。我如何使用约束布局来实现这一点?
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:visibility="gone"
app:layout_constraintTop_toBottomOf="@+id/search_view"
android:layout_height="0dp"
app:layout_constraintHeight_default="wrap"
app:layout_constraintHeight_max="500dp"
android:scrollbars="vertical"/>
【问题讨论】:
-
内容大于最大高度会怎样?
-
@FrancescoBocci 然后它的工作正常包装内容
-
在约束布局中使用指南并将单位更改为百分比并将回收者视图约束为指南
标签: android android-layout android-recyclerview android-constraintlayout