减少 Jetpack Compose 中 TextField 标签和下划线之间的差距

时间:2021-05-12 12:23:22

标签: android textfield android-jetpack-compose

在我的 TextField 中,默认情况下标签和下划线之间有很多差距。

这是它的样子:

My textfields:

如何缩小差距?

这是我的最顶层 TextField 的代码:

            val query = remember { mutableStateOf("") }
           
            TextField(
                value = query.value,
                onValueChange = { newValue -> query.value = newValue },
                label = {
                    Text(
                        "Name as on PAN Card",
                        color = colorResource(id = R.color.bright_green),
                        fontSize = with(LocalDensity.current) {
                            dimensionResource(id = R.dimen._9ssp).toSp()
                        })
                },
                textStyle = TextStyle(
                    textAlign = TextAlign.Start,
                    color = colorResource(id = R.color.bright_green),
                    fontFamily = FontFamily(Font(R.font.poppins_regular)),
                    fontSize = with(LocalDensity.current) {
                        dimensionResource(id = R.dimen._16ssp).toSp()
                    },
                ),
                modifier = Modifier
                    .constrainAs(name) {
                        top.linkTo(glName)
                        start.linkTo(parent.start)
                        end.linkTo(parent.end)
                    },
                colors = TextFieldDefaults.textFieldColors(

                    backgroundColor = Color.Transparent,
                    unfocusedIndicatorColor = colorResource(id = R.color.bright_green),
                    focusedIndicatorColor = colorResource(id = R.color.bright_green)
                )
            )

0 个答案:

没有答案