https://kotlinlang.org logo
#compose
Title
# compose
d

dorche

11/22/2023, 6:43 PM
Hi everyone, I feel like I am going crazy - something that should be very basic doesn't quite work as expected. My Text seems to have some extra padding although it shouldn't. Code is super short in 🧵. 🙏 Any ideas what is wrong here?
Copy code
@Preview(widthDp = 225)
@Composable
fun TextPadding() = PreviewSurface {
    Column(
        horizontalAlignment = Alignment.CenterHorizontally,
        verticalArrangement = Arrangement.Center
    ) {
        Text("Column Centered")
        Row(
            verticalAlignment = Alignment.CenterVertically,
            horizontalArrangement = Arrangement.Center
        ) {
            IconButton(onClick = { }) {
                Icon(Icons.Default.AccountBox, contentDescription = "")
            }
            Text(
                text = "Your new Account Value",
                textAlign = TextAlign.Center,
                fontSize = 24.sp,
                modifier = Modifier.weight(1f, false)
            )
            IconButton(onClick = { }) {
                Icon(Icons.Default.AccountBox, contentDescription = "")
            }
        }
    }
}
The result of this is:
but I would expect "Your new Account Value" to not have that extra space around it
Adding
IntrinsicSize.Min
to the Text doesn't solve it either, as that forces it to go on new line for each word:
I feel like I'm missing something obvious here...
z

Zach Klippenstein (he/him) [MOD]

11/22/2023, 8:41 PM
You’re using compose 1.1? That is a very old version. Newer versions have this flag: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/PlatformTextStyle#PlatformTextStyle(kotlin.Boolean)
d

dorche

11/22/2023, 8:43 PM
I'm on 1.6.0-alpha06 actually, but I don't think this flag is about the same thing.
I think this is another (well, same) repro for that issue I linked above