Home:ALL Converter>Android Basic TextField alignment in Jetpack Compose

Android Basic TextField alignment in Jetpack Compose

Ask Time:2021-09-22T05:42:47         Author:arieliito

Json Formatter

i am having problemas trying to align text in a BasicTextField inside a ROW in Jetpack Compose, the goal is to have the text in total center.

The code is the following:

Row(verticalAlignment = Alignment.CenterVertically,
        horizontalArrangement = Arrangement.Center
    ) {

        BasicTextField(
            modifier = Modifier
                .height(40.dp)
                .align(Alignment.CenterVertically),
            value = "Hello",
            onValueChange = {},
            singleLine = true,
            textStyle = LocalTextStyle.current.copy(textAlign = TextAlign.Center),
        )
    }

Here is a picture of the result:

enter image description here

Any ideas what's wrong?

Thanks!

Ariel

Author:arieliito,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/69275864/android-basic-textfield-alignment-in-jetpack-compose
yy