I\'m using really naive code to show a bottom sheet dialog fragment:
class LogoutBottomSheetFragment : BottomSheetDialogFragment() {
override fun onCrea
Use follow API to setContentView instead of overriding onCreateView.
val dialog = BottomSheetDialog(context)
dialog.setContentView(R.layout.your_layout)
BottomSheetDialog.setContentView will setup the correct behavior for BottomSheetDialog. You can see the source code:
public void setContentView(@LayoutRes int layoutResId) {
super.setContentView(this.wrapInBottomSheet(layoutResId, (View)null, (LayoutParams)null));
}
private View wrapInBottomSheet(int layoutResId, View view, LayoutParams params) {
FrameLayout container = (FrameLayout)View.inflate(this.getContext(), layout.design_bottom_sheet_dialog, (ViewGroup)null);
CoordinatorLayout coordinator = (CoordinatorLayout)container.findViewById(id.coordinator);
if (layoutResId != 0 && view == null) {
view = this.getLayoutInflater().inflate(layoutResId, coordinator, false);
}
// ... more stuff
}