How do I change the default height of a BottomSheetDialog?

change peek height programmatically android
bottomsheet set peek height
bottom sheet dialog with edittext android
bottomsheetdialogfragment behavior
bottomsheetdialogfragment wrap content
bottomsheetdialogfragment custom behavior
bottom sheet dialog fragment disable drag
bottom sheet dialog not show full

I've been using the new BottomSheetDialog added in Support Library 23.2, but I want to change the default height of the dialog. I know it probably has to do with the behavior_peekHeight attribute which controls the initial height, but how do I set that in the BottomSheetDialog when I don't have direct access to the BottomSheetBehavior?

You can set a bottomSheetDialogTheme in your Activity, overriding the bottomSheetStyle attribute's behavior_peekHeight:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
  <item name="bottomSheetDialogTheme">@style/AppBottomSheetDialogTheme</item>

<style name="AppBottomSheetDialogTheme"
  <item name="bottomSheetStyle">@style/AppModalStyle</item>

<style name="AppModalStyle"
  <item name="behavior_peekHeight">@dimen/custom_peek_height</item>

This same technique can be used for other attributes as well, such as adding <item name="behavior_hideable">true</item> to the AppModalStyle to change whether the bottom sheet is hideable.

How do I change the default height of a BottomSheetDialog?, I've been using the new BottomSheetDialog added in Support Library 23.2, but I want to change the default height of the dialog. I know it probably has to do with  Answers: I found a much simpler answer; in your example where you obtain the FrameLayout for the bottom sheet using this code. View bottomSheet = dialog.findViewById (; you can then set the height on the layout params for that View to whatever height you want to set the expanded height to.

you can use BottomSheetBehaviorin your code

BottomSheetDialog dialog = new BottomSheetDialog(content);
BottomSheetBehavior mBehavior = BottomSheetBehavior.from((View) view.getParent());
mBehavior.setPeekHeight(your dialog height);

How do I change the default height of a BottomSheetDialog , Questions: I've been using the new BottomSheetDialog added in Support Library 23.2, but I want to change the default height of the dialog. but this will not be a smooth transition. You will be able to clearly notice a state change. To open the bottom sheet to full screen without a noticeable animation change, you need to add an onShowListener on the onCreate function of the BottomSheetDialogFragment which will be called as soon as the bottom sheet appears and set the peek height to device’s height.


<style name="BottomSheetDialog" parent="Theme.Design.Light.BottomSheetDialog">
    <item name="bottomSheetStyle">@style/bottomSheetStyleWrapper</item>

<style name="bottomSheetStyleWrapper" parent="Widget.Design.BottomSheet.Modal">
    <item name="behavior_peekHeight">500dp</item>

BottomSheetDialog dialog = new BottomSheetDialog(this,;

How do I change the default height of a BottomSheetDialog?, bottomsheetdialogfragment set peek height the view is not associated with bottomsheetbehavior android bottom sheet animation duration persistent bottom​  I faced the same issue, when trying to update the peek height based on its contents, the height from a previous layout was found. This makes sense as the new layout had not taken place yet. By posting on the UI thread the layout height is calculated after the new layout, and another layout request is made to update the bottom sheet to the right

Another way is inheriting BottomSheetDialogFragment and have control how and when you set the content view. Going up the view tree, you can get the behavior that BottomSheetDialog wraps up the content view. It's not really good solution, because it requires more layout passes. It is important that when the state of the bottom sheet is STATE_HIDDEN we have to dismiss the dialog, if we don't we clearly violate the implementation provided in the library.

After setting the peek height programmatically, content view must call requestLayout() which is indeed another layout pass.

public class CustomBottomSheetDialogFragment extends BottomSheetDialogFragment {

    private BottomSheetBehavior.BottomSheetCallback mBottomSheetBehaviorCallback = new BottomSheetBehavior.BottomSheetCallback() {

        public void onStateChanged(@NonNull View bottomSheet, int newState) {
            if (newState == BottomSheetBehavior.STATE_HIDDEN) {


        public void onSlide(@NonNull View bottomSheet, float slideOffset) {

    public void setupDialog(Dialog dialog, int style) {
        super.setupDialog(dialog, style);
        View contentView = View.inflate(getContext(), R.layout.bottom_sheet_dialog_content_view, null);
        mBottomSheetBehavior = BottomSheetBehavior.from(((View) contentView.getParent()));
        if (mBottomSheetBehavior != null) {

BottomSheetBehavior, I've been using the new BottomSheetDialog added in Support Library 23.2, but I want to change the default height of the dialog. I know it probably has to If the RecyclerView content is filled inside initRecyclerView (contentView); then when showing BottomSheet it's height is well known. To set the height of BottomSheet dynamically and to wrap the content then add global layout listener inside onResume function of the BottomSheetDialogFragment:

Woks for me

  override fun onStart() {
    dialog?.also {
        val bottomSheet = dialog.findViewById<View>(
        bottomSheet.layoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT
        val behavior = BottomSheetBehavior.from<View>(bottomSheet)
        behavior.peekHeight = resources.displayMetrics.heightPixels //replace to whatever you want

Hands-on with Material Components for Android: Bottom Sheets, as a bottom sheet. To send useful accessibility events, set a title on bottom sheets that are windows or are window-like. For BottomSheetDialog use setTitle(​int) , and for Gets the height of the bottom sheet when it is collapsed. The default value is 0, which results in the sheet matching the parent's top. // You may have to measure your content view first. dialog.setContentView(contentView); // Change this to a percentage or a constant, whatever you want to do. // The default is 1024 - any views smaller than this will be pulled off // the bottom of the screen. float peekHeight = contentView.getMeasuredHeight(); View parent = (View)contentView.getParent(); BottomSheetBehavior behavior = BottomSheetBehavior.from(parent); behavior.setPeekHeight(peekHeight); CoordinatorLayout.LayoutParams

BottomSheetDialogFragment with peekHeight equals to screen height, Setting up a Material Components theme for Android also makes use of BottomSheetBehavior in a BottomSheetDialog class to convert a The default value is auto , which sets the peek height at the 16:9 ratio keyline of the  "Note that you cannot call the method before view layouts." The above text is the clue. Dialogs have a listener that is fired once the dialog is shown.The dialog cannot be shown if it isn't laid out.

How cani controll the height of bottom sheet ?i tried , Initially, the bottom sheet can cover a defined height of the screen and the user can drag is upwards to show it on full You can achieve this by programmatically setting two values. val d = dialog as BottomSheetDialog. Re: How can I change the default for wall height/depth mode? In addition to setting the Unconnected Height, you can constrain the top of your walls to the desired level. Surprisingly, when I changed the default height in both cases, saved and reopened my Projects, the default was saved.

Bottom Sheets, If you are trying to adjust the peek height, I found I had to extend and BottomSheetDialog dialog = new BottomSheetDialog(getContext(),  And this could be a totally wrong way to handle it, but I also want my scroll view to never be larger than the height of the parent view. To accomplish this I went this route: in init() edit: This code is in the actual RelativeLayout (or whatever you want to use) view that resides in the sheet (the view that slides up/down into place).