Reputation: 2436
I have layout like this:
<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
and RecyclerView
have dynamic sizes, and FragmentContainerView
should not be less than 300dp
and fit all available spase. RecyclerView
should be on the bottom and can contains from 1 to 20 items. Current solution works ok only for case RecyclerView
contains few items, but for other case it overlaps FragmentContainerView
.
Is it possible to align RecyclerView
to bottom but restrict max size to have free space = 300dp at the top?
Upvotes: 1
Views: 2585
Reputation: 40810
I think you need to do:
app:layout_constraintTop_toBottomOf="@id/container"
to the RecyclerView
app:layout_constraintBottom_toTopOf="@+id/recyclerView"
From the FragmentContainerView
This will make the FragmentContainerView
height not restricted to the height of the RecyclerView
.. and Make the RecyclerView
height limited between the bottom of the FragmentContainerView
& the bottom of the parent.
Upvotes: 1
Reputation: 173
Try adding app:layout_constraintTop_toBottomOf="@id/container"
in RecyclerView
Upvotes: 0