var textStyle by remember { mutableStateOf(textStyleBody1) }
var readyToDraw by remember { mutableStateOf(false) }
BasicTextField(
value = input,
onValueChange = { value ->
//内容发生变化 就说明还没发送
showClear = false
onInput(value);
},
modifier = Modifier
.fillMaxWidth()
.padding(18.dp)
.drawWithContent { if (readyToDraw) drawContent() },
cursorBrush = SolidColor(if (showClear) Color.Transparent else Color.White),
textStyle = textStyle,
//自动变小
onTextLayout = { textLayoutResult ->
if (textLayoutResult.size.height > ScreenUtil.getScreenWidth(context)) {
textStyle = textStyle.copy(fontSize = textStyle.fontSize * 0.9)
} else {
readyToDraw = true
}
},
)
Compose BasicTextField fontSize 字体大小 AutoSize超过一定高度后自动变小
于 2022-11-02 18:47:42 首次发布