如何更改android compose TextFeild的内容填充?

秦文浩*_*秦文浩 9 android kotlin android-jetpack-compose

填充太大了!我可以删除它们吗?

\n
TextField(\n            value = text,\n            textStyle = TextStyle(\n                color = Color.Red,\n                textDecoration = TextDecoration.None\n            ),\n            onValueChange = {\n                text = it\n            },\n            placeholder = {\n                Text(text = "\xe8\xaf\xb7\xe8\xbe\x93\xe5\x85\xa5\xe8\xae\xbe\xe5\xa4\x87\xe5\xba\x8f\xe5\x88\x97\xe5\x8f\xb7", color = Color.Gray)\n            },\n            singleLine = true,\n            activeColor = Color.Yellow,\n            modifier = Modifier.padding(1.dp),\n            backgroundColor = Color.Transparent\n        )\n
Run Code Online (Sandbox Code Playgroud)\n

这是我的代码。请帮助我!

\n

Abd*_*een 1

您可以使用 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()
                }
            )
Run Code Online (Sandbox Code Playgroud)