如何在 Jetpack Compose 中的 TextField(提示)中定位文本?

时间:2021-04-21 16:25:13

标签: android alignment android-jetpack-compose

我在 TextField 中创建了一个文本作为提示。我想减少下划线和提示文本之间的距离。我怎么做?我尝试使用以下代码:

      TextField(
                value = query.value,
                onValueChange = { newValue -> query.value = newValue },
                label = {
                    Text(
                        "Name as on Pan Card",
                        color = colorResource(id = R.color.fade_green),
                        modifier = Modifier.align(BottomCenter) //THIS LINE PRODUCES ERROR
                    )
                },
                textStyle = TextStyle(
                    textAlign = TextAlign.Start,
                    color = colorResource(id = R.color.fade_green),
                    fontFamily = FontFamily(Font(R.font.poppins_regular)),
                    fontSize = with(LocalDensity.current){
                            dimensionResource(id = R.dimen._11ssp).toSp()},
                ),
                modifier = Modifier
                    .align(
                        CenterHorizontally
                    )
                    .weight(0.3f),
                colors = TextFieldDefaults.textFieldColors(

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

我收到错误 'fun Modifier.align(alignment : Alignment) : Modifier can't be called in this context by implicit receiver. Use the explicit one if necessary'

我该如何解决这个问题?

0 个答案:

没有答案