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 just set param "maxHeight" to the root viewgroup of your bottom sheet. android:maxHeight=500dp.
behavior_peekHeight attribute value used to represent how much pixels the bottom sheet will be visible. I set it to `0dp` because, later in the sample I wanted to demonstrate how to peek the sheet programmatically. BottomSheetBehavior allows the peek height being given programmatically.
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> <style name="AppBottomSheetDialogTheme" parent="Theme.Design.Light.BottomSheetDialog"> <item name="bottomSheetStyle">@style/AppModalStyle</item> </style> <style name="AppModalStyle" parent="Widget.Design.BottomSheet.Modal"> <item name="behavior_peekHeight">@dimen/custom_peek_height</item> </style>
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With