Hi everyone, can we customize text field like this...
# compose
c
Hi everyone, can we customize text field like this one or have to create compounded compose view?
a
c
Thanks @Anastasia Rozovskaya but I tried it not able to get right aligned error message like in the image , rest image able to achieve by overriding color attribute
n
? you can just wrap your textfield in a column
Copy code
Column {
    TextField(value = "", onValueChange = {})
    if(error != null) {
        Text(text = "Error: $error", color = Color.Red, modifier = Modifier.align(Alignment.End))
    } 
}
1
b
I think that’s the OP’s question/point. you can’t do it with JUST a
TextField
, you have to use a wrapper (
Column
) and another
Text
composable for the error.
💯 2
☝️ 2
n
Ah yes I misread, But it's actually a sample on the link provided by anastasia :
So I'm not sure about what
I tried it not able to get right aligned error message like in the image
meant
d
@Ch8n It's a shame that you got a couple of misleading replies here - those respondents did not comprehend your question properly. @Bradleycorn is correct: the basic
TextField
does not provide for an additional label, in the position you've shown. I also required this to build a 'form' component with validation, and ended up building a composite component from
TextField
and
Text
in a
Column
.
👍 1
c
Thanks guys for replied, In XML android components we had til and that could be used to shift alignment of error using some hacks. But I guess with compose I have to make compounded one. Anyways I'm have more custom requirements Im making it using basic text field. And handle lables and error states on my own. Cc @darkmoon_uk @Bradleycorn @nitrog42