Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Align the Icon to the End in TopAppBar jetpack compose

Now the icon always in the start, what should I do to align the icon to the end? I tried to use modifier but doesn't work. Thank you in advance.

enter image description here

enter image description here

like image 835
Harvey Xie Avatar asked Dec 14 '25 13:12

Harvey Xie


1 Answers

If you want an Icon aligned at the end in the TopAppBar use the actions parameter instead of the navigationIcon.

Something like:

TopAppBar(
    title = { Text("Simple TopAppBar") },
    backgroundColor = Red,
    actions = {
        // RowScope here, so these icons will be placed horizontally
        IconButton(onClick = { /* doSomething() */ }) {
            Icon(Icons.Filled.Close, contentDescription = null)
        }
    }
)

enter image description here

like image 165
Gabriele Mariotti Avatar answered Dec 16 '25 08:12

Gabriele Mariotti



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!