Dragos Rachieru
09/10/2023, 8:58 AMBadgedBox
, but the badge is not placed correctly in my UI:Dragos Rachieru
09/10/2023, 8:59 AMCenterAlignedTopAppBar
, in its actions
lambda, you can see the result at the bottom of the screenshotAlexander Maryanovsky
09/10/2023, 9:58 AMDragos Rachieru
09/10/2023, 10:18 AM@OptIn(ExperimentalMaterial3Api::class)
@Composable
private fun TestWindow() {
Window(onCloseRequest = {}) {
Scaffold(
topBar = {
CenterAlignedTopAppBar(
title = { Text("Badged") },
actions = {
BadgedBox(badge = { Badge { Text("box") } }) {
IconButton(onClick = {}) {
Icon(Icons.Default.Check, contentDescription = null)
}
}
IconButton(onClick = {}) {
Icon(Icons.Default.Close, contentDescription = null)
}
}
)
}
) {
Text("Badged Box", modifier = Modifier.padding(it))
}
}
}
Dragos Rachieru
09/10/2023, 10:21 AMIconButton
and the Text
Alexander Maryanovsky
09/10/2023, 10:27 AMAlexander Maryanovsky
09/10/2023, 10:27 AMBox(Modifier.fillMaxSize()) {
BadgedBox(
modifier = Modifier.align(Alignment.Center).border(1.dp, Color.Black),
badge = {
Badge { Text("100") }
}
) {
IconButton(onClick = {}) {
Icon(Icons.Default.Check, contentDescription = null)
}
}
}
Dragos Rachieru
09/10/2023, 10:35 AMTopAppBar
and I cannot make it draw over the IconButton
Dragos Rachieru
09/10/2023, 10:35 AMAlexander Maryanovsky
09/10/2023, 10:36 AMAlexander Maryanovsky
09/10/2023, 10:45 AMAlexander Maryanovsky
09/10/2023, 10:45 AM@OptIn(ExperimentalMaterial3Api::class)
fun main() = singleWindowApplication {
CenterAlignedTopAppBar(
title = {
Text("Title")
},
actions = {
BadgedBox(
modifier = Modifier
.padding(horizontal = 24.dp)
.border(1.dp, Color.Black),
badge = {
Badge { Text("100") }
}
) {
IconButton(
onClick = {},
modifier = Modifier.size(30.dp)
) {
Icon(Icons.Default.Check, contentDescription = null)
}
}
}
)
}
Alexander Maryanovsky
09/10/2023, 10:50 AMAlexander Maryanovsky
09/10/2023, 10:52 AMDragos Rachieru
09/10/2023, 11:01 AM