它的填充太大了!我可以删除它们吗?
TextField(
value = text,
textStyle = TextStyle(
color = Color.Red,
textDecoration = TextDecoration.None
),
onValueChange = {
text = it
},
placeholder = {
Text(text = "请输入设备序列号", color = Color.Gray)
},
singleLine = true,
activeColor = Color.Yellow,
modifier = Modifier.padding(1.dp),
backgroundColor = Color.Transparent
)
这是我的代码。请帮助我!
答案 0 :(得分:0)
您可以使用 BasicTextField 来控制它。
var value by rememberSaveable { mutableStateOf("") }
BasicTextField(
cursorBrush = SolidColor(Color.White),
value = value,
onValueChange = { value = it },
textStyle = TextStyle(color = Color.White),
decorationBox = { innerTextField ->
Row(modifier = Modifier.fillMaxWidth()) {
if (value.isEmpty()) {
Text(text = "Placeholder", color = Color.White)
}
}
innerTextField()
}
)