I'm trying to make an editText which fills the width of the screen, and it's hint and input starts from the center of the screen.
I choose BasicTextField, since the styles of TextField and OutlinedTextFields are completely unnecessary to me.
I've tried doing this.
BasicTextField(
value = loginId,
onValueChange = {
loginId = it
},
decorationBox = {
Text(text = "Input your id", modifier = Modifier.align(Alignment.CenterHorizontally).fillMaxWidth())
},
modifier = Modifier
.fillMaxWidth()
.padding(start = 19.dp,
bottom = 4.5.dp, end = 19.dp, top = 40.dp)
.background(Purple200)
.align(Alignment.CenterHorizontally),
)
This has no effect. What can I do with this?
You can apply
TextAlign.Center
to yourText
. You can use thestyle
or thetextAlign
properties. Something like:or:
Also to work correctly, since you are using the
decorationBox
, you must callinnerTextField
exactly once inside yourdecorationBox
. Something like: