Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to change android compose TextFeild`s content padding?

It`s padding is to large!what can i delete them?

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
        )

this is my code.please help me !

like image 992
秦文浩 Avatar asked May 30 '26 12:05

秦文浩


1 Answers

You can use BasicTextField to take control over it.

            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()
                }
            )
like image 143
Abdul Mateen Avatar answered Jun 02 '26 03:06

Abdul Mateen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!