ConstraintLayout 从下到上
ConstraintLayout from bottom to top
我有这样的布局:
<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
并适合所有可用空间。 RecyclerView
应该在底部,可以包含 1 到 20 个项目。当前的解决方案仅适用于 RecyclerView
包含少量项目的情况,但对于其他情况它重叠 FragmentContainerView
。
是否可以将 RecyclerView
对齐到底部但限制最大尺寸以在顶部有可用的 space = 300dp?
尝试在 RecyclerView
中添加 app:layout_constraintTop_toBottomOf="@id/container"
我认为你需要做的:
- 将
app:layout_constraintTop_toBottomOf="@id/container"
添加到 RecyclerView
- 从
FragmentContainerView
中删除 app:layout_constraintBottom_toTopOf="@+id/recyclerView"
这将使 FragmentContainerView
高度不限于 RecyclerView
的高度 .. 并使 RecyclerView
高度限制在 FragmentContainerView
的底部 & parent.
的底部
我有这样的布局:
<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
并适合所有可用空间。 RecyclerView
应该在底部,可以包含 1 到 20 个项目。当前的解决方案仅适用于 RecyclerView
包含少量项目的情况,但对于其他情况它重叠 FragmentContainerView
。
是否可以将 RecyclerView
对齐到底部但限制最大尺寸以在顶部有可用的 space = 300dp?
尝试在 RecyclerView
中添加app:layout_constraintTop_toBottomOf="@id/container"
我认为你需要做的:
- 将
app:layout_constraintTop_toBottomOf="@id/container"
添加到RecyclerView
- 从
FragmentContainerView
中删除
app:layout_constraintBottom_toTopOf="@+id/recyclerView"
这将使 FragmentContainerView
高度不限于 RecyclerView
的高度 .. 并使 RecyclerView
高度限制在 FragmentContainerView
的底部 & parent.