layout_behavior - android.support.design.widget.BottomSheetBehavior is not working
this view is not constrained vertically at runtime it will jump
I am getting this error in Androidx only. So how i can resolve this error.
<?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:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#efefef"
tools:context=".MainActivity">
<include layout="@layout/content_main" />
<!-- Adding bottom sheet after main content -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/bottom_sheet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#fff"
android:orientation="vertical"
android:padding="10dp"
app:behavior_hideable="true"
app:behavior_peekHeight="56dp"
app:layout_behavior="android.support.design.widget.BottomSheetBehavior">
...... child layouts..
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

Since you are using androidx libraries, you have to use the Material Components Library.
Use the class com.google.android.material.bottomsheet.BottomSheetBehavior instead of android.support.design.widget.BottomSheetBehavior:
<LinearLayout
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior"
..>
or:
<LinearLayout
app:layout_behavior="@string/bottom_sheet_behavior"
..>
Also change the ConstraintLayout to CoordinatorLayout.
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