timrijckaert
06/27/2021, 11:31 AMRow with some weighted `Text`'s inside, however how can I make the Row clip the Text?
Do I need a fixed width - height for the Row and calculate the TextStyle fontSize manually or is there a better alternative?
@Composable
fun Eclipse() {
Row(
modifier = Modifier
.height(IntrinsicSize.Min)
.width(IntrinsicSize.Min)
.background(Color.Black)
) {
EclipseIntTile(0, modifier = Modifier.weight(1F))
EclipseIntTile(4, modifier = Modifier.weight(1F))
EclipseIntTile(5, modifier = Modifier.weight(1F))
EclipseIntTile(2, modifier = Modifier.weight(1F))
}
}
@Composable
fun EclipseIntTile(i: Int, modifier: Modifier = Modifier) {
Text("$i", modifier = modifier, style = TextStyle(fontSize = 140.sp, color = Color.White))
}
Any pointers?
Thankstimrijckaert
06/27/2021, 11:36 AMJelle Fresen [G]
06/28/2021, 11:50 AMModifier.clipToBounds() and TextAlign.CenterJelle Fresen [G]
06/28/2021, 11:52 AMJelle Fresen [G]
06/28/2021, 11:53 AM@Composable
fun ClippedTextDemo() {
Row {
val modifier = Modifier.weight(1f).clipToBounds()
val textStyle = LocalTextStyle.current.copy(
fontSize = 240.sp,
textAlign = TextAlign.Center
)
Text("0", modifier, style = textStyle)
Text("4", modifier, style = textStyle)
Text("5", modifier, style = textStyle)
Text("2", modifier, style = textStyle)
}
}Jelle Fresen [G]
06/28/2021, 11:54 AMtimrijckaert
07/21/2021, 9:04 AM