mattinger
05/22/2025, 4:37 PM@Preview
@Composable
fun PreviewSingleButton() {
Scaffold {
Box(modifier = Modifier.padding(it)) {
TextButton(
onClick = {},
shape = RectangleShape,
modifier = Modifier,
) {
Text("This is the secondary CTA. It is long and will go to another line and another line")
Spacer(modifier = Modifier.width(4.dp))
Icon(
modifier = Modifier.requiredSize(16.dp),
painter = painterResource(android.R.drawable.arrow_down_float),
contentDescription = null
)
}
}
}
}
When i run this preview, it seems that the measurement is way off when i have long blurbs of text (yes i know buttons should have short concise text, but i don't have control over the text). It seems like it's not respecting the sizing properly and it's overlapping the icon and the text. I also tried using the size
modifier on the icon instead, but when i do that, it doesn't appear at all and the layout inspector indicates that it's measured at zero width.stantronic
05/22/2025, 5:29 PMmaxLines =1
and overflow = TextOverflow.Ellipsis
on the Text.stantronic
05/22/2025, 5:33 PMmattinger
05/22/2025, 6:18 PMAditya Bhaskar
05/24/2025, 6:34 AMweight(1f)
on the text. That will place the text last after the icon and the spacer, and it'll only occupy the remaining space.