How to position alert dialog in Jetpack Compose to the bottom of the screen. Also, set transparent background.
Thanks, @alekseyHunter & @johann. I can able to achieve this with custom layout modifier.
Custom modifier to position alert dialog
enum class CustomDialogPosition {
BOTTOM, TOP
}
fun Modifier.customDialogModifier(pos: CustomDialogPosition) = layout { measurable, constraints ->
val placeable = measurable.measure(constraints);
layout(constraints.maxWidth, constraints.maxHeight){
when(pos) {
CustomDialogPosition.BOTTOM -> {
placeable.place(0, constraints.maxHeight - placeable.height, 10f)
}
CustomDialogPosition.TOP -> {
placeable.place(0,0,10f)
}
}
}
}
And in alert dialog implementation as
AlertDialog( ..., modifiers = Modifiers.customDialogModifier(CustomDialogPosition.BOTTOM))
{
// block
})