BottomSheetDialogFragment with peekHeight equals to screen height

Updated 29 March 2019


What is BottomSheetDialogFragment?

BottomSheetDialogFragment is a version of DialogFragment which is shown from the bottom instead of a floating dialog. Google introduced this in its Android version 23. It is used to show the additional content of the page and they have a nicer-looking entrance animation and since they are pinned to the bottom they may feel easier to use on larger devices. For detailed documentation, You can follow the official doc.

What is Peek Height?

Bottom Sheets have various states like STATE_COLLAPSED, STATE_EXPANDED, STATE_DRAGGING, STATE_SETTLING, and STATE_HIDDEN. Initially, the bottom sheet can cover a defined height of the screen and the user can drag is upwards to show it on full screen or the user can drag it downwards to dismiss it. When it is covering a definite height then it is in STATE_COLLAPSED state, when it is covering the full screen then it is in STATE_EXPANDED, and when it not shown on the screen then it is in STATE_HIDDEN. So, In case of STATE_COLLAPSED, the height for which the bottom sheet is showed is called the peek height which can be assigned as the below-given codes.

Hows the peeking bottom sheet looks like?

Here is an image of the bottom sheet peeking.


How to open the bottom sheet directly to full screen?

Recently, We got into a situation where we wanted to show a full-screen bottom layout directly (without the STATE_COLLAPSED). You can achieve this by programmatically setting two values.

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.

Hope this has helped you in getting the idea of what exactly happening.

That’s all for this blog. Thank you very much. This is Vedesh Kumar signing off.

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


  • kunj
    • Vedesh Kumar (Moderator)
  • Veerendra N k
  • Veerendra N k
  • Tiago A
  • Start a Project

      Message Sent!

      If you have more details or questions, you can reply to the received confirmation email.

      Back to Home