Anonymous
Как DatePickerDialog может находиться над содержимым?
Сообщение
Anonymous » 10 мар 2024, 03:26
При использовании
it is above other content even if one does not use a
layout around it. How is that possible?
Sample code:
Код: Выделить всё
OutlinedTextField(
enabled = true,
singleLine = true,
modifier = Modifier.fillMaxWidth(),
placeholder = { Text("field 1") },
value = "",
onValueChange = {}
)
OutlinedTextField(
enabled = true,
singleLine = true,
modifier = Modifier.fillMaxWidth(),
placeholder = { Text("field 2") },
value = "",
onValueChange = {}
)
OutlinedTextField(
enabled = true,
singleLine = true,
modifier = Modifier.fillMaxWidth(),
placeholder = { Text("field 3") },
value = "",
onValueChange = {}
)
val datePickerState = rememberDatePickerState()
val showDialog = rememberSaveable { mutableStateOf(true) }
if(showDialog.value) {
DatePickerDialog(
onDismissRequest = { /* kein cancel wenn außerhalb des Dialogs tippe */ },
confirmButton = {
TextButton(onClick = {}) {
Text("ok")
}
},
dismissButton = {
TextButton(onClick = { }) {
Text("cancel")
}
}
) {
DatePicker(state = datePickerState)
}
}
Result:
Источник:
https://stackoverflow.com/questions/781 ... he-content
1710030410
Anonymous
При использовании[code]DatePickerDialog[/code] it is above other content even if one does not use a [code]Box[/code] layout around it. How is that possible? Sample code: [code] OutlinedTextField( enabled = true, singleLine = true, modifier = Modifier.fillMaxWidth(), placeholder = { Text("field 1") }, value = "", onValueChange = {} ) OutlinedTextField( enabled = true, singleLine = true, modifier = Modifier.fillMaxWidth(), placeholder = { Text("field 2") }, value = "", onValueChange = {} ) OutlinedTextField( enabled = true, singleLine = true, modifier = Modifier.fillMaxWidth(), placeholder = { Text("field 3") }, value = "", onValueChange = {} ) val datePickerState = rememberDatePickerState() val showDialog = rememberSaveable { mutableStateOf(true) } if(showDialog.value) { DatePickerDialog( onDismissRequest = { /* kein cancel wenn außerhalb des Dialogs tippe */ }, confirmButton = { TextButton(onClick = {}) { Text("ok") } }, dismissButton = { TextButton(onClick = { }) { Text("cancel") } } ) { DatePicker(state = datePickerState) } } [/code] Result: [img]https://i.stack.imgur.com/oUyZE.png[/img] Источник: [url]https://stackoverflow.com/questions/78133819/how-does-the-datepickerdialog-manage-to-be-above-the-content[/url]