'RecyclerView does not show all items inside BottomSheetDialogFragment

I have BottomSheetDialogFragment with an input field and RecyclerView. ConstraintLayout has height set at match_parent and RecylcerView's height is 0dp.

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/bottom_sheet"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="android.support.design.widget.BottomSheetBehavior">

    <EditText
        android:id="@+id/et_enter_text"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:backgroundTint="@color/black"
        android:hint="Enter a city"
        android:layout_marginTop="20dp"
        android:textColor="@color/black"
        android:textColorHint="@color/black"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        tools:ignore="Autofill,TextFields" />


    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/rv_result"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/et_enter_text"
        app:layout_constraintVertical_bias="0" />

</androidx.constraintlayout.widget.ConstraintLayout>

The problem is that RecyclerView shows just 6 of 9 elements when the keyboard is open.

The keyboard is overlapping RecyclerView even when android:windowSoftInputMode is set to adjustResize. Desired behavior is to make RecyclerView bottom constraint attached to the top of the keyboard.

See screenshot

This is style for bottom sheet.

<style name="AppBottomSheetDialogTheme"
      parent="Theme.Design.Light.BottomSheetDialog">
      <item name="android:windowSoftInputMode">adjustResize</item>
</style>


Solution 1:[1]

This seems to be quick similar to this issue.

Adding

app:layout_constrainedHeight="true"

to the RecyclerView like it was suggested in [1] [2] did work for me

Solution 2:[2]

Please use LinearLayout instead of constraint layout because sometimes expected weird behavior when recycler view inside constraint layout

<LinearLayout>
....
<RecyclerView/>
</LinearLayout>

Solution 3:[3]

Change ConstraintLayout to LinearLayout. I had the same problem, which got resolved by this method.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Rui Rodrigues
Solution 2
Solution 3 Jeremy Caney