Jozef Forgáč
Jozef Forgáč

Reputation: 1

Material 3 DatePickerDialog container width

I'm trying to change the width of container of DatePickerDialog, but it never scales well when i try to change the width by modifier.width. I tried the sample implementation which is on android developer but couldn't move further with the width.. Thank you for all the answers.

https://developer.android.com/reference/kotlin/androidx/compose/material3/package-summary#DatePickerDialog(kotlin.Function0,kotlin.Function0,androidx.compose.ui.Modifier,kotlin.Function0,androidx.compose.ui.graphics.Shape,androidx.compose.ui.unit.Dp,androidx.compose.material3.DatePickerColors,androidx.compose.ui.window.DialogProperties,kotlin.Function1)

val datePickerState = rememberDatePickerState() val confirmEnabled = derivedStateOf { datePickerState.selectedDateMillis != null } DatePickerDialog( modifier = Modifier.requiredWidth(200.dp), onDismissRequest = { openDialog = false }, properties = DialogProperties(usePlatformDefaultWidth = false), confirmButton = { TextButton( onClick = { openDialog = false }, enabled = confirmEnabled.value, colors = ButtonDefaults.buttonColors(),

            ) {
                Text("OK")
            }
        },
        dismissButton = {
            TextButton(
                onClick = {
                    openDialog = false
                },
                colors = ButtonDefaults.buttonColors()
            ) {
                Text("Cancel")
            }
        },
        colors = DatePickerDefaults.colors()
    ) {
        DatePicker(state = datePickerState,
            colors = DatePickerDefaults.colors())
    }

this is my code

Upvotes: 0

Views: 484

Answers (1)

Oleksandr
Oleksandr

Reputation: 11

I faced the same problem.Try using Modifier.scale()

Upvotes: 1

Related Questions