Creating Custom Bottom Sheet Dialog

BottomSheet dialog is a beautiful view of the android application.
mostly bottom sheet dialog is used to show some content which can be a swipe up and down.

Here you can check how to implement custom bottom dialog.

1- Create an android project
2- Do the following changes in your style.xml under res.


download full source code of the custom bottom dialog sheet.
Github Link

<style name="CustomBottomSheetDialogTheme" 
    <item name="bottomSheetStyle">

<style name="CustomBottomSheetStyle"
<item name="android:background">

3- create a blank fragment and extend it with BottomSheetDialogFragment

FilterBottomfragment extends BottomSheetDialogFragment

4- inflate your custom layout within fragment like this

public View onCreateView(@NonNull LayoutInflater inflater,
@Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {

//inflate your custom layout in place of bottom_dialog
View view=inflater.inflate(R.layout.bottom_dialog,container,false);
return view;

5- apply the style in fragment's onCreate() like this

public void onCreate(@Nullable Bundle savedInstanceState) {

6- open the dialog on clicking of a button or on any event

btnOpenDialog.setOnClickListener(new View.OnClickListener()
public void onClick(View v) {
FilterBottomfragment filterBottomFragment = new FilterBottomfragment();
//set filterBottomFragment.setCancelable(true)
//if you want to cancel on touch out side;

No comments:

Post a Comment