I've created a bottom sheet that swipes up when a button on the screen is clicked. The main activity is a map - with a button that expands the bottom sheet. I'm using the Material Bottom sheet library.
Main Screen: Hidden Bottom Sheet
Expanded Bottom Sheet on click: Expanded Sheet
mBottomSheetBehavior = BottomSheetBehavior.from(mBottomSheet);
mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_HALF_EXPANDED);
}
});
Here's want I want to implement:
Instead of having to press a button to expand the sheet, I want the user to be able to swipe up and open the bottom sheet.
This is what I want the bottom sheet to look like hidden.
I've tried using Gesture Listener but that doesn't seem to work - since the main screen has a map. It only moves the map around and swipe isn't recognized.
I'm fairly new to android so I'd really appreciate the help.
In your bottom sheet layout xml, add this code
app:behavior_peekHeight="20dp" // change the dp as your need