I have been trying to implement bottom sheet fragment in android and have been unable to scale it to full screen by default. I have even tried to set it's state to STATE_EXPANDED
public void setupDialog(Dialog dialog, int style) {
super.setupDialog(dialog, style);
View v = View.inflate(getContext(), R.layout.fragment_my_bottom_sheet_dialog, null);
dialog.setContentView(v);
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) ((View) v.getParent()).getLayoutParams();
CoordinatorLayout.Behavior behavior = params.getBehavior();
if (behavior != null && behavior instanceof BottomSheetBehavior) {
Log.d(TAG, "Inside if");
((BottomSheetBehavior) behavior).setState(BottomSheetBehavior.STATE_EXPANDED);
((BottomSheetBehavior) behavior).setBottomSheetCallback(mBottomSheetCallback);
}
}
But this messes up the animation of sheet floating upwards from bottom. I am trying to create a modal bottom sheet with a full screen and toolbar with a close(X) button like this
I would really appreciate if someone could help me out with it.