I am trying to set hidden state for BottomSheet
, but it doesn't work. What's the problem?
bottomBar = BottomSheetBehavior.from(findViewById(R.id.bottom_bar));
bottomBar.setState(BottomSheetBehavior.STATE_HIDDEN);
Bottom Sheet is a well-written material design component that performs enter/exit animations, respond to dragging/swiping gestures, etc. For using it in your project you should implement next dependencies into your app build.gradle file: implementation "androidx.coordinatorlayout:coordinatorlayout:1.1.0"
Bottom sheets are supplementary surfaces primarily used on mobile. There are three types suitable for different use cases: Standard bottom sheets display content that complements the screen's primary content. They remain visible while users interact with the primary content.
The modal Bottom sheet always appears from the bottom of the screen and if the user clicks on the outside content then it is dismissed. It can be dragged vertically and can be dismissed by sliding it down.
Disable drag of BottomSheetDialogFragment Even if we have made the BottomSheetDialogFragment as expanded, user can hold the top part of the BottomSheet and drag to show peek view. It can also be disabled by overriding onStateChanged() . This will set the expanded state even if user drags the view.
Remember to add this while hiding the bottom sheet at start of activity/fragment
bottomSheetBehavior =BottomSheetBehavior.from(bottom_sheet_view_here);
bottomSheetBehavior.setHideable(true);//Important to add
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
mBottomSheetBehaviour.setPeekHeight(0);
use this and it will hide.
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