【发布时间】:2021-01-06 23:02:05
【问题描述】:
我有这样的布局:
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.fragment.app.FragmentContainerView
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="@color/colorPrimary"
android:minHeight="300dp"
app:layout_constraintBottom_toTopOf="@+id/recyclerView"
app:layout_constraintHeight_min="300dp"
app:layout_constraintTop_toTopOf="parent" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
FragmentContainerView 和 RecyclerView 具有动态大小,FragmentContainerView 不应小于 300dp 并适合所有可用的 spase。 RecyclerView 应该在底部,可以包含 1 到 20 个项目。当前解决方案仅适用于RecyclerView 包含少量项目的情况,但对于其他情况,它与FragmentContainerView 重叠。
是否可以将RecyclerView 与底部对齐但限制最大尺寸以使可用空间 = 300dp 在顶部?
【问题讨论】:
-
你能添加一些截图发生了什么吗?
标签: android android-constraintlayout