Android -Working with Bottom Sheet
What is Bottom Sheet in Android ?
Android Bottom Sheet is a sheet that slides up from the bottom edge of the screen.
Android Bottom Sheet component slides up from the bottom showing some more options to the user. You can notice bottom sheets in apps like map apps (bottom sheet reveals location, directions information), music players (Play bar sticks to bottom and opens when swipe up).
Types of Bottom Sheet
- Modal Bottom Sheets
- Persistent Bottom Sheet
In this post will learn about Modal Bottom Sheets
Modal Bottom Sheets:
As the name suggests, these sheets behave like Modals or
dialogues. It have higher elevation than the app. It shadows the activity or fragment when activated. And if we tap outside the Bottom Sheet, it is dismissed just like a modal. A user can also slide up and slide down to activate and deactivate the Bottom Sheet, respectively. Below are the examples of modal bottom sheet of Google Drive app.
Modal Bottom Sheets implementation
Step 1: create style for the bottom sheet
Step 2: design resource layout that you want to show in bottom sheet
Step 3: In MainActivity.java initialize the BottomSheetDialog and take your XML file that define a layout, and converting them into View objects. Then set the content of the view to BottomSheetDialog object