how to put button in top right most corner in jetpack compose
Asked Answered
C

1

6

I do not know how to put button at top right most corner of the screen in jetpack compose.Please help me with the code?

I have added button but it is showing at the centre of the screen

Corbicula answered 4/11, 2022 at 5:14 Comment(0)
D
7

Can you try this?

@Composable
fun MyScreen() {
    Box(
        modifier = Modifier.fillMaxSize()
    ){
        Button(
            modifier = Modifier.align(Alignment.TopEnd),
            onClick = {}
        ) {
            Text("A Button")
        }
    }
}

enter image description here

Dragoon answered 4/11, 2022 at 5:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.