I have fragment inherited of BottomSheetDialogFragment. It's layout is ConstraintLayout and consist of:
TextView (header)
RecyclerView (list of my addresses)
LinearLayout (image + editText for add new address)
Button (confirmation of choice)
<?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/bottomSheet" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/bottom_sheet_background" android:padding="14dp" app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior"> <TextView android:id="@+id/header" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_margin="12dp" android:text="My addresses" android:textSize="24sp" android:textStyle="bold" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> <androidx.recyclerview.widget.RecyclerView android:id="@+id/rv" android:layout_width="match_parent" android:layout_height="wrap_content" app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" app:layout_constrainedHeight="true" app:layout_constraintBottom_toTopOf="@id/addNewAddress" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/header" tools:listitem="@layout/address_delivery_item" /> <LinearLayout android:id="@+id/addNewAddress" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toBottomOf="@id/rv" app:layout_constraintBottom_toTopOf="@id/button"> <ImageView android:id="@+id/addNewAddressButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:src="@drawable/ic_add_button"/> <EditText android:id="@+id/addNewEditText" android:layout_width="match_parent" android:layout_height="48dp" android:layout_weight="1" android:layout_gravity="center" android:textSize="12dp" android:hint="Add new address"/> </LinearLayout> <com.google.android.material.button.MaterialButton android:id="@+id/button" style="@style/Button.Contained" android:background="@drawable/app_confirm_button" android:text="SELECT" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" /> </androidx.constraintlayout.widget.ConstraintLayout>
My expectation is to show fragment with height by content + field for new address + button in both behavior state (STATE_COLLAPSED and STATE_EXPANDED)
When I open this fragment in STATE_EXPANDED behavior, all shows correct: screenshot STATE_EXPANDED behavior
When I open this fragment in STATE_COLLAPSED behavior,button and editText doesn't appear: screenshot STATE_COLLAPSED behavior
I tried to bind and unbind RecyclerView to LinearLayout(id/addNewAddress) but in doesn't help.
Does anyone have any ideas how to achieve this behavior? to make the button appear in STATE_COLLAPSED?
I will be very grateful for the help!