Bottom Sheet Dialog implementation in kotlin

Needone App
1 min readDec 17, 2022

--

To implement a bottom sheet dialog in Kotlin, you can use the BottomSheetDialog class from the Android Support Library.

Here’s an example of how you can use a BottomSheetDialog in Kotlin:

In the example above, we create a new instance of BottomSheetDialog and pass it the current context. Then, we inflate the layout for the bottom sheet and set it as the content view of the dialog using the setContentView() method. Finally, we show the bottom sheet dialog using the show() method.

You can customize the behavior of the bottom sheet dialog by setting the BottomSheetBehavior of the bottom sheet's view. For example, you can set the state of the behavior to STATE_COLLAPSED to make the bottom sheet collapsed by default, or set the peekHeight to specify the height of the collapsed bottom sheet.

val bottomSheetBehavior = BottomSheetBehavior.from(view.findViewById(R.id.bottom_sheet))
bottomSheetBehavior.state = BottomSheetBehavior.STATE_COLLAPSED
bottomSheetBehavior.peekHeight = 200

Originally published at https://needone.app on December 17, 2022.

--

--

No responses yet