I have this layout:
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
...
<FrameLayout
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="200dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />
</android.support.constraint.ConstraintLayout >
This recyclerview is added to the "id/content" framelayout
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:layout_gravity="bottom"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
app:layoutManager="LinearLayoutManager" />
It has the desirable effect that the recyclerview is placed at the bottom of the screen.
The problem arises when there are many viewholders in the recyclerview. I would like to leave some room at the top to still see the map (200dp margin). I've tried lots of ways and can't seem to find an elegant solution. Essentially what I want is that the recyclerview will wrap_content until that content is too big. If the content is too big, I want the recyclerview to expand to fill the space it can, while leaving 200dp at the top. In iOS this would be possible using a >= 200 constraint. Is this possible on android? How?
Ah! I forgot to add a vertical constraint to the top. Changing the FrameLayout to this did the trick.
<FrameLayout
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="200dp"
app:layout_constraintTop_toBottomOf="@id/appBarLayout"
app:layout_constraintBottom_toBottomOf="parent" />
I think that the problem comes from the hierarchy of your layouts.
Adding the RecyclerView to android.R.id.content adds it to the same level of the ConstraintLayout, maybe if you add it directly to the ConstraintLayout and apply to it some constraints, you can achieve What your want.
Although, BottomSheetBehavior maybe be the component that you want to mimic?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With