Somesh Shukla
Somesh Shukla

Reputation: 61

how to put button in top right most corner in jetpack compose

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

Upvotes: 6

Views: 4289

Answers (1)

z.g.y
z.g.y

Reputation: 6207

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

Upvotes: 7

Related Questions