Disabling User dragging on BottomSheet
Solution 1
It can be now no longer relevant, but I will leave it here:
import android.content.Context
import android.util.AttributeSet
import androidx.coordinatorlayout.widget.CoordinatorLayout
import android.view.MotionEvent
import android.view.View
import com.google.android.material.bottomsheet.BottomSheetBehavior
@Suppress("unused")
class LockableBottomSheetBehavior<V : View> : BottomSheetBehavior<V> {
constructor() : super()
constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
var swipeEnabled = true
override fun onInterceptTouchEvent(
parent: CoordinatorLayout,
child: V,
event: MotionEvent
): Boolean {
return if (swipeEnabled) {
super.onInterceptTouchEvent(parent, child, event)
} else {
false
}
}
override fun onTouchEvent(parent: CoordinatorLayout, child: V, event: MotionEvent): Boolean {
return if (swipeEnabled) {
super.onTouchEvent(parent, child, event)
} else {
false
}
}
override fun onStartNestedScroll(
coordinatorLayout: CoordinatorLayout,
child: V,
directTargetChild: View,
target: View,
axes: Int,
type: Int
): Boolean {
return if (swipeEnabled) {
super.onStartNestedScroll(
coordinatorLayout,
child,
directTargetChild,
target,
axes,
type
)
} else {
false
}
}
override fun onNestedPreScroll(
coordinatorLayout: CoordinatorLayout,
child: V,
target: View,
dx: Int,
dy: Int,
consumed: IntArray,
type: Int
) {
if (swipeEnabled) {
super.onNestedPreScroll(coordinatorLayout, child, target, dx, dy, consumed, type)
}
}
override fun onStopNestedScroll(
coordinatorLayout: CoordinatorLayout,
child: V,
target: View,
type: Int
) {
if (swipeEnabled) {
super.onStopNestedScroll(coordinatorLayout, child, target, type)
}
}
override fun onNestedPreFling(
coordinatorLayout: CoordinatorLayout,
child: V,
target: View,
velocityX: Float,
velocityY: Float
): Boolean {
return if (swipeEnabled) {
super.onNestedPreFling(coordinatorLayout, child, target, velocityX, velocityY)
} else {
false
}
}
}
And use it in your xml file:
app:layout_behavior="com.your.package.LockableBottomSheetBehavior"
It disables all users actions, it can be used when you want control BottomSheet only programmatically.
Solution 2
check state in onStateChanged
method of setBottomSheetCallback
if state is BottomSheetBehavior.STATE_DRAGGING
then change it to BottomSheetBehavior.STATE_EXPANDED
this way you can stop STATE_DRAGGING
by user. like below
final BottomSheetBehavior behavior = BottomSheetBehavior.from(bottomSheet);
behavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
@Override
public void onStateChanged(@NonNull View bottomSheet, int newState) {
if (newState == BottomSheetBehavior.STATE_DRAGGING) {
behavior.setState(BottomSheetBehavior.STATE_EXPANDED);
}
}
@Override
public void onSlide(@NonNull View bottomSheet, float slideOffset) {
}
});
use button to open close bottom sheet like below
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (behavior.getState() == BottomSheetBehavior.STATE_HIDDEN) {
behavior.setState(BottomSheetBehavior.STATE_EXPANDED);
} else {
behavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
}
}
});
don't use setPeekHeight
or app:behavior_peekHeight
by above way you can reach your goal
Solution 3
implementation 'com.google.android.material:material:1.2.0-alpha05'
you can disable dragging the BottomSheet like this.
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val dialog = BottomSheetDialog(requireContext(), theme)
dialog.setOnShowListener {
setBottomSheetExpanded(dialog)
}
return dialog
}
open fun setBottomSheetExpanded(bottomSheetDialog: BottomSheetDialog) {
val bottomSheet =
bottomSheetDialog.findViewById<View>(R.id.design_bottom_sheet) as FrameLayout?
bottomSheet?.let {
val behavior: BottomSheetBehavior<*> = BottomSheetBehavior.from(bottomSheet)
val layoutParams = bottomSheet.layoutParams
bottomSheet.layoutParams = layoutParams
behavior.state = BottomSheetBehavior.STATE_EXPANDED
behavior.isDraggable = false / true
}
}
Edited) The library was updated! you can use new library version
implementation 'com.google.android.material:material:1.4.0'
The examples are the same, good luck and good code
Solution 4
Alright, so the accepted answer didn't work for me. However, Виталий Обидейко's answer inspired my final solution.
First, I created the following custom BottomSheetBehavior. It overrides all of the methods involving touch, and returns false (or did nothing) if it is locked. Otherwise, it acts like a normal BottomSheetBehavior. This disables the user's ability to drag down, and does not affect changing the state in code.
LockableBottomSheetBehavior.java
public class LockableBottomSheetBehavior<V extends View> extends BottomSheetBehavior<V> {
private boolean mLocked = false;
public LockableBottomSheetBehavior() {}
public LockableBottomSheetBehavior(Context context, AttributeSet attrs) {
super(context, attrs);
}
public void setLocked(boolean locked) {
mLocked = locked;
}
@Override
public boolean onInterceptTouchEvent(CoordinatorLayout parent, V child, MotionEvent event) {
boolean handled = false;
if (!mLocked) {
handled = super.onInterceptTouchEvent(parent, child, event);
}
return handled;
}
@Override
public boolean onTouchEvent(CoordinatorLayout parent, V child, MotionEvent event) {
boolean handled = false;
if (!mLocked) {
handled = super.onTouchEvent(parent, child, event);
}
return handled;
}
@Override
public boolean onStartNestedScroll(CoordinatorLayout coordinatorLayout, V child, View directTargetChild, View target, int nestedScrollAxes) {
boolean handled = false;
if (!mLocked) {
handled = super.onStartNestedScroll(coordinatorLayout, child, directTargetChild, target, nestedScrollAxes);
}
return handled;
}
@Override
public void onNestedPreScroll(CoordinatorLayout coordinatorLayout, V child, View target, int dx, int dy, int[] consumed) {
if (!mLocked) {
super.onNestedPreScroll(coordinatorLayout, child, target, dx, dy, consumed);
}
}
@Override
public void onStopNestedScroll(CoordinatorLayout coordinatorLayout, V child, View target) {
if (!mLocked) {
super.onStopNestedScroll(coordinatorLayout, child, target);
}
}
@Override
public boolean onNestedPreFling(CoordinatorLayout coordinatorLayout, V child, View target, float velocityX, float velocityY) {
boolean handled = false;
if (!mLocked) {
handled = super.onNestedPreFling(coordinatorLayout, child, target, velocityX, velocityY);
}
return handled;
}
}
Here's an example of how to use it. In my case, I needed it so the Bottom Sheet locked when expanded.
activity_home.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|snap"
app:titleEnabled="false"/>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"/>
</android.support.design.widget.AppBarLayout>
<!-- Use layout_behavior to set your Behavior-->
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layoutManager="android.support.v7.widget.LinearLayoutManager"
app:layout_behavior="com.myapppackage.LockableBottomSheetBehavior"/>
</android.support.design.widget.CoordinatorLayout>
HomeActivity.java
public class HomeActivity extends AppCompatActivity {
BottomSheetBehavior mBottomSheetBehavior;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recyclerview);
recyclerView.setAdapter(new SomeAdapter());
mBottomSheetBehavior = BottomSheetBehavior.from(recyclerView);
mBottomSheetBehavior.setBottomSheetCallback(new MyBottomSheetCallback());
}
class MyBottomSheetCallback extends BottomSheetBehavior.BottomSheetCallback() {
@Override
public void onStateChanged(@NonNull View bottomSheet, int newState) {
if (newState == BottomSheetBehavior.STATE_EXPANDED) {
if (mBottomSheetBehavior instanceof LockableBottomSheetBehavior) {
((LockableBottomSheetBehavior) mBottomSheetBehavior).setLocked(true);
}
}
}
@Override
public void onSlide(@NonNull View bottomSheet, float slideOffset) {}
});
}
Hope this helps clear up a lot of the confusion!
Solution 5
I ended up writing a workaround to address this use case of dynamically disabling user dragging, whereby BottomSheetBehavior is subclassed to override onInterceptTouchEvent, and to ignore it when a custom flag (in this case mAllowUserDragging) is set to false:
import android.content.Context;
import android.support.design.widget.BottomSheetBehavior;
import android.support.design.widget.CoordinatorLayout;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
public class WABottomSheetBehavior<V extends View> extends BottomSheetBehavior<V> {
private boolean mAllowUserDragging = true;
/**
* Default constructor for instantiating BottomSheetBehaviors.
*/
public WABottomSheetBehavior() {
super();
}
/**
* Default constructor for inflating BottomSheetBehaviors from layout.
*
* @param context The {@link Context}.
* @param attrs The {@link AttributeSet}.
*/
public WABottomSheetBehavior(Context context, AttributeSet attrs) {
super(context, attrs);
}
public void setAllowUserDragging(boolean allowUserDragging) {
mAllowUserDragging = allowUserDragging;
}
@Override
public boolean onInterceptTouchEvent(CoordinatorLayout parent, V child, MotionEvent event) {
if (!mAllowUserDragging) {
return false;
}
return super.onInterceptTouchEvent(parent, child, event);
}
}
And in your layout xml:
<FrameLayout
android:id="@+id/bottom_sheet_frag_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:behavior_hideable="true"
app:behavior_peekHeight="@dimen/bottom_sheet_peek_height"
app:elevation="@dimen/bottom_sheet_elevation"
app:layout_behavior="com.example.ray.WABottomSheetBehavior" />
So far, this is the most consistently behaving solution for disabling user dragging on the Bottom Sheet on demand.
All of the other solutions that relied on firing another setState call in the onStateChanged callback resulted in the BottomSheet getting into a bad state, or causes significant UX issues (in the case of posting the setState call in a Runnable).
Hope this helps someone :)
Ray
Tonespy
Updated on January 28, 2022Comments
-
Tonespy over 2 years
I am trying to disable user dragging on
BottomSheet
. The reason I want to disable is two things. 1. It's preventing theListView
from scrolling downward, 2. I don't want users to dismiss using dragging but with a button on theBottomSheetView
. This is what I've donebottomSheetBehavior = BottomSheetBehavior.from(bottomAnc); bottomSheetBehavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() { @Override public void onStateChanged(@NonNull View bottomSheet, int newState) { if (newState == BottomSheetBehavior.STATE_EXPANDED) { //Log.e("BottomSheet", "Expanded"); } else if (newState == BottomSheetBehavior.STATE_COLLAPSED) { //Log.e("BottomSheet", "Collapsed"); } } @Override public void onSlide(@NonNull View bottomSheet, float slideOffset) { // React to dragging events bottomSheet.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { int action = MotionEventCompat.getActionMasked(event); switch (action) { case MotionEvent.ACTION_DOWN: return false; default: return true; } } }); } });
The bottomSheetLayout
<?xml version="1.0" encoding="utf-8"?><FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/white" app:behavior_hideable="true" app:behavior_peekHeight="0dp" app:layout_behavior="@string/bottom_sheet_behavior" android:id="@+id/bottomSheet"> <android.support.v7.widget.CardView android:layout_width="match_parent" android:layout_height="match_parent" app:elevation="10dp"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:gravity="center_vertical"> <TextView android:id="@+id/text1" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="Order Items" android:layout_margin="16dp" android:textAppearance="@android:style/TextAppearance.Large"/> <Button android:layout_width="50dp" android:layout_height="wrap_content" android:layout_marginRight="5dp" android:background="@drawable/bg_accept"/> <Button android:layout_width="50dp" android:layout_height="wrap_content" android:layout_marginRight="8dp" android:background="@drawable/bg_cancel"/> </LinearLayout> <ListView android:id="@+id/item_edit" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/white" android:divider="@color/md_divider_black" android:dividerHeight="1dp"/> </LinearLayout> </android.support.v7.widget.CardView>
-
Tonespy about 8 yearsNice trick. Didn't notice that. Thanks. And also, can you help with this. When I tell it to expand at first, it's transparent and I can see the view behind, but I can't interact not until I tap on the EditText in the SheetView before making it visible.
-
Tonespy about 8 yearsI made my
BottomSheet View
match_parent
and whenever I try to bring it up in myActivity
I noticed it slides up, but it's not visible not until I tap theEditText
in it which brings up theKeyboard
and make theBottomSheet View
visible -
Tonespy about 8 yearsYeah. It's like it's active but totally transparent and not visible but responds to touch.
-
Dhaval Parmar about 8 yearsfor this you need bottom sheet layout have more content other wise its not show you as match_parent. I don't think its work as what you want.
-
Tonespy about 8 yearsLet me tell you the problem with throwing it in a runnable unless that's what you want. You can't dismiss it with a button because, it needs to drag to dismiss. And, it'll always respond to dragging, just that it would prevent the user from dragging to dismiss
-
Gokhan Arik about 8 yearsI tried this, but the states ends up in
STATE_SETTLING
. I have a button to open and close bottom sheet, if it is HIDDEN, I expand it. If it is EXPANDED, I hide it. Since it gets stuck in SETTLING, my button doesn't work after dragging bottom sheet. Any idea on that? -
Ray W about 8 yearsThis solution is unreliable; the bottom sheet gets into a bad state, as Gokhan said... and when in that bad state, calls like loading a new fragment into the bottom sheet will simply blank out.
-
Odys about 8 yearsThat's pretty neat
-
Beeing Jk almost 8 yearsGood solution but it doesn't work when there is a listview in the bottom sheet.
-
Afzal N over 7 years@BeeingJk Instead of the FrameLayout, use NestedScrollView, and set
bottomSheetFragContainer.setNestedScrollingEnabled(false);
-
LOG_TAG over 7 yearsHow make it usable for MapView (to avoid zooming problems )
-
LOG_TAG over 7 years@AfzalivE it will work for MapView in BootomSheetFragment?
-
LOG_TAG over 7 yearsSOLVED: by setting callback CoordinatorLayout.Behavior behavior = layoutParams.getBehavior(); if (behavior != null && behavior instanceof BottomSheetBehavior) { ((BottomSheetBehavior) behavior).setBottomSheetCallback(mBottomSheetBehaviorCallback); }
-
murt over 7 yearsI use this apporach in order to manage simultanously 4 bottom sheet at once. The problem I have is when i disable onInterceptTouchEvent() in all MyBottomSheetBehaviour the last BottomSheet is still draggable
-
murt over 7 yearsThis is the best answer, for disabling BottomSheetBehaviour. A man above also posted similiar solution, but he didn't write to override others event like onTouchEvent(). In other hand you may improve your answer if you put a flag instead of false
-
Vitalii Obideiko over 7 years@murt, thanks. I posted this because in some cases other answers give me wrong behavior. Only if override all method we can obtain useful result. I think that who needs the flag can easy add it :)
-
Thorvald over 7 yearsThis doesn't wok for me ! PS : I have a scrollable text in the bottomsheet
-
Hammad Nasir over 7 yearsthis also seems to be helpful: stackoverflow.com/a/38723483/6144372
-
Tunga over 7 yearsThis solution was appealing but bizarrely causes the bottom sheet to appear from the top of the screen instead of the bottom! It disappears the normal way however. It's very Star Trek.
-
Leonid Ustenko about 7 yearsHow do you cast it during initialisation? This gives me warning WABottomSheetBehavior<View> behaviour = (WABottomSheetBehavior) BottomSheetBehavior.from(sheetView);
-
ᴛʜᴇᴘᴀᴛᴇʟ about 7 years@ВиталийОбидейко this is great! thank you! i tried all answer. Only this worked. Thanks a lot!
-
eRaisedToX about 7 yearsThis works for
persistent bottom sheets
of mine but is not working formodal bottom sheets
..Any idea why? -
HolySamosa over 6 yearsI needed to make a sight modification and instead use
BottomSheetBehavior.STATE_HIDDEN
. In such case, you must also not callsetPeekHeight()
. This is much less complicated than other solutions here. -
Kailas Bhakade over 6 yearsIt worked for me. Thanks, But little bit doubt about that Is it correct way?
-
Dhaval Parmar over 6 yearsthere is not correct way to do something. whatever work for you choose it. and be prepare to change.
-
Vivek Kumar Srivastava over 6 yearsthis one is a perfect answer
-
Tấn Nguyên about 6 yearsNice, it's best answer that we can avoid workaround these states which lead to miss events. Thank you.
-
user3144836 about 6 yearsHow do you use this class? I'm getting an IllegalArgumentException: The view is not associated with BottomSheetBehavior
-
user3144836 about 6 yearsHow do you use this class? I'm getting an IllegalArgumentException: The view is not associated with BottomSheetBehavior
-
user3144836 about 6 yearsHow do you use this with a BottomSheetFragment ?
-
Rishabh Chandel about 6 yearsIt will not work if you have nestedscrollview inside bottom sheet
-
Metwalli about 6 yearsapp:layout_behavior="UserLockBottomSheetBehavior"> in xml and then in code you do the following. // get the bottom sheet view LinearLayout llBottomSheet = (LinearLayout) findViewById(R.id.bottom_sheet); // init the bottom sheet behavior BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.from(llBottomSheet);
-
Steve almost 6 yearsYou need to specifically refer to this class in your XML. app:layout_behavior="com.my.package.UserLockBottomSheetBehavior"
-
Adarsh Yadav over 5 years@James - Nice answer but now I am not able to setPeekHeight(). Any idea?
-
Deepak Joshi over 5 yearsIn some cases, this still doesn't work, if we have a list in bottom sheet fragment, it still drags
-
Vitalii Obideiko over 5 years@DeepakJoshi this solution was for static content. Need to look into scrollable content problem
-
Vitalii Obideiko over 5 years@DeepakJoshi what did you use Recycler or smth else?
-
Deepak Joshi over 5 years@ВиталийОбидейко, Yes, I used recycler view and when I try to scroll down on the area where recycler view is there, the parent bottom sheet also starts dragging.
-
Vitalii Obideiko over 5 years@DeepakJoshi I think it is because of developer.android.com/reference/android/support/v7/widget/… implements developer.android.com/reference/android/support/v4/view/…. But how u could fix it I can't suggest right now
-
Vitalii Obideiko over 5 years@DeepakJoshi maybe u may extends of RecyclerView and override few methods like 'hasNestedScrollingParent', but I am not sure
-
Deepak Joshi over 5 years@ВиталийОбидейко, thanks for the quick reply, currently I have changed the approach, but I will surely try this.
-
Usman Rana over 5 yearsSometimes it stucks and stay locked even dragging is allowed
-
AdamHurwitz over 5 yearsThis does not disable swiping. It collapses the bottom sheet completely.
-
AdamHurwitz over 5 yearsThis is not ideal as it may cause unexpected animations.
-
AdamHurwitz over 5 yearsThis causes unexpected animation when the Bottom Sheet is attempting to close.
-
pz64_ over 5 yearsIn my case. It didn't caused any animations issue at all. It just don't move after card is expanded. It's not ideal but it did work as expected!
-
AdamHurwitz over 5 yearsInteresting, that could be the case. I resolved the issue with my Bottom Sheet closing unexpectedly by setting the CollapsingToolbarLayout's Toolbar to Invisible or Gone when the Bottom Sheet is open. A touch interaction related to the Toolbar even though it was underneath was causing the Bottom Sheet to close unexpectedly. The issue is fixed now.
-
Sup.Ia over 5 yearsI tried this. it works for me. thanks bro for saving my ass
-
Ajay over 5 yearsThis is a good workaround, although it is not updated as of today. The OnNestedPreScroll and certain other methods have been deprecated. Need to update those methods and it works just fine.
-
Debdeep about 5 years@DeepakJoshi You might have certainly used
SwipeRefreshLayout
. Exclude that and bottom sheet won't be dragging down onRecyclerView
up scroll. -
Deepak Joshi about 5 years@Debdeep, I was using RecyclerView, now I have changed my use case.
-
Antroid about 5 yearsthis trick is somewhat irrelevant if user experience is concerned, as it makes the bottom sheet behaviour abnormal. The sheet collapses when user taps anywhere .when the sheet's state is : Expanded
-
Abhishek about 5 yearsThis doens't work. Follow the previous answer where it has been shown how to override other methods.
-
florian-do about 5 yearsHello, it doesn't work on a BottomSheetDialogFragment, i can still drag the bottomsheet
-
Eric Bachhuber almost 5 yearsNice concise solution. To anyone reading this, you'll (probably) want additional checks for
event.isCanceled()
andevent.getAction() == MotionEvent.ACTION_UP
before dismissing the dialog -- this will prevent mis-clicks from firing the dismissal. -
Aman Verma over 4 yearssetBottomSheetCallback is deprecated API 28 not working crashing
-
zoha131 over 4 yearsWhat is the negative effect of using
setPeekHeight
? I have setbehavior.peekHeight = Int.MAX_VALUE
and it's working for me. I am not sure if it has any side effects. -
AVJ over 4 yearsThanks for this. This is the simplest solution to disable dragging.
-
Aman Verma over 4 years@RishabhChandel did you find the solution yet?
-
Quentin vk over 4 yearsthis works if you set var swipeEnabled = false for recyclerview in bottomsheet as well.
-
Pranav P over 4 yearsVery solutions. But not sure why it did not work for me. Any thoughts @VitaliiObideiko I am using Viewpager with recyclerView. :(
-
Tyler about 4 yearsWorks if you swap out the deprecated methods for the ones that include the extra type int parameter
-
Yuri Popiv about 4 yearsit doesn't work with
NestedScrollView
@RishabhChandel you saved my day! Many thanks!!! -
Gastón Saillén about 4 yearsFor some reason, I cant close the dialog touching outside, but it works to disable the drag
-
Fayçal almost 4 yearsit's for iOS here not Android
-
Nirav Joshi almost 4 years@VitaliiObideiko how to change swipeEnabled value dynamically ?
-
Vitalii Obideiko almost 4 years@NiravJoshi just add public method where you may set value to it
-
Bob almost 4 yearsIn case of netstedscrollview, also set
isNestedScrollingEnabled
to false -
Isuru Bandara over 3 yearsThis method does not work if you are using nestedscrollview, It is working with Scrollview.
-
DavidHyogo over 3 yearsThe question is very detailed with plenty of relevant code to explain the problem, but it's hard to see the connection between your answer and the question because you haven't added any explanation to your code sample.
-
Ram Chhabra over 3 years@DavidHyogo sorry for no explanation I added.. but as in the question user wanted to disable bottom sheet dragging property so I suggested to use setCancelable(false); method of bottom sheet
-
sweet_vish about 3 yearsI am getting below issue- Could not inflate Behavior subclass com.rp.th.sit.order.cart.presentation.view.cartutil.LockableBottomSheetBehavior why is it?
-
Gabriel Trifa almost 3 yearsThank you! This worked for me. Just one comment: should be used sheetBehavior.addBottomSheetCallback instead of setBottomSheetCallback, which is deprecated.
-
Hank Chan almost 3 yearsThis seriously needs to be the default answer. I've wasted precious time to try all the solutions before this one, and none compares with it.
-
Burak over 2 yearsThis worked perfect for me. Thank you!
-
Abdullah over 2 yearsit works perfect but
setBottomSheetCallback
depreciated! please useaddBottomSheetCallback
-
Pradeep Simba over 2 yearsI can't understand this answer. So , please explain in detail.