bodo
10/25/2021, 10:03 AMText("This is a test", modifier = Modifier.dynamicTextSize(14.sp))
• composable width <=100dp it should use the specified 14.sp
• composable width > 100dp it should use the specified 14.sp multiplied with a scale factor -> e.g. scalefactor = 1.5 * 14.sp = 21.sp
Can you please show me how to achieve this best? ThxLucien Guimaraes
10/25/2021, 10:14 AMmaxWidth
you can edit your text sizebodo
10/25/2021, 11:09 AMAlbert Chang
10/25/2021, 1:27 PMbodo
10/25/2021, 5:17 PM@Composable
fun DynamicText(text: String, fontSize: Sp) {
BoxWithConstraint {
val textSize = if (maxWidth > 100) fontSize * 1.5 else fontSize
TextSize(text = text, fontSize = textSize)
}
}
Or can i do better?