Compose IconButton offset centerHorizontal alignment within Column

34 Views Asked by At

I have the following composable for Android:

IconButton({}) {
                Column(
                    modifier = Modifier.fillMaxSize(),
                    verticalArrangement = Arrangement.Center,
                    horizontalAlignment = Alignment.CenterHorizontally
                ) {
                    Icon(Icons.Filled.Notifications, contentDescription = "notify")
                    Text("Notify", fontSize = 8.sp, maxLines = 1,
                        overflow = TextOverflow.Clip, softWrap = false)
                }
            }

This shows in the Preview in Android Studio as:

enter image description here

How can I fix this so the Icon is centered horizontally within the Column (or is this a Preview bug - which I don't believe)?

Thank you

I'm using Material3 - here are some of my imports:

import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Home
import androidx.compose.material3.Button
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.Text
0

There are 0 best solutions below