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>
Error resolve by replacing
androidx.constraintlayout.widget.ConstraintLayout
to
androidx.coordinatorlayout.widget.CoordinatorLayout
and
app:layout_behavior="android.support.design.widget.BottomSheetBehavior"
to
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior"
in activity_main.xml
Correct code is.
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
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="com.google.android.material.bottomsheet.BottomSheetBehavior">
...... child layouts..
</LinearLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>