raenardev
09/04/2025, 2:39 PMautoSize
for BasicText
BasicText(
text = "Hello World",
maxLines = 1,
autoSize = TextAutoSize.StepBased()
)
Is there something like that for BasicTextField
? It would be nice to scale font in input fields as wellraenardev
09/04/2025, 2:42 PMonTextLayout = { if (it.hasVisualOverflow) fontSize *= 0.99f }
but besides that?Halil Ozercan
09/05/2025, 6:44 PMBasicText
. It is a bit ambiguous to define it for BasicTextField
since it supports scrolling. For now your best option is to use TextMeasurer to do a binary search to find the proper font size.
https://gist.github.com/halilozercan/40ec1cc005e0b41e836a7ad21c127dcd
https://gist.github.com/halilozercan/d1468efa45c4e9a71907623e41c2ccb7
I have these gists from 3 years ago that may be a bit out of date but they employ the same TextMeasurer idea. You can simply ignore the AutosizeBasicText
composable.