build.gradle
compile 'com.android.support:design:<latest-library-version>'
Create a class that extends BottomSheetDialogFragment , inflated with the layout that will be used as the content of the modal dialog.
public class BottomSheetFragment extends BottomSheetDialogFragment { public BottomSheetFragment() { // Required empty public constructor } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment return inflater.inflate(R.layout.fragment_bottom_sheet, container, false); } }
Create an instance of the modal bottom sheet and show it with the show method, passing the FragmentManager and a string tag as parameters.
CustomBottomSheetDialog bottomSheetDialog = CustomBottomSheetDialog.getInstance(); bottomSheetDialog.show(getSupportFragmentManager(), "Custom Bottom Sheet");
References
https://github.com/mhdr/AndroidSamples/tree/master/096
https://mayojava.github.io/android/bottom-sheets-android/