3

In xml based layouts we can set app:autoSizeTextType="uniform" in the edit text to auto size the text font. But similar feature is not available in compose TextField. Please suggest if there is any alternative way of doing it.

Phil Dukhov
  • 67,741
  • 15
  • 184
  • 220
Abhishek
  • 86
  • 6

1 Answers1

1

You can try following solution

@Composable
fun Int.scaledSp(): TextUnit {
    val value: Int = this
    return with(LocalDensity.current) {
        val fontScale = this.fontScale
        val textSize =  value / fontScale
        textSize.sp
  }
Pritesh Patel
  • 678
  • 17
  • 35