One last thing: The suffix/prefix will only be visible when the view is focused 馃槈
_Originally posted by @kroegerama in https://github.com/material-components/material-components-android/issues/1427#issuecomment-647332783_
Is it possible to somehow change this behavior?
My use case is: in the text input for phone number I'm displaying area code as a prefix.
It would be nice if the area code is visible all the time, regardles of the current focus.
It's visible when focused or when the EditText is filled.
For my use case it would be great if is visible even if the input is empty and not focused.
User picks country using spinner, usually before entering the phone number so they expect the area code to be visible immediately after choosing the country.
Can't you use the hint attribute? It's always visible, if the EditText is empty.
Thanks, it solves the problem!
However I still believe that changing the prefix behavior to be always displayed or making it configurable (maybe some app:prefixAlwaysVisible attribute) could be a good idea.
Now, to show my area code correctly I had to use setOnFocusChangeListener and update hint to empty string after gaining focus (otherwise both prefix and hint were visible on empty focused input).
Is there any update about it?
Most helpful comment
Thanks, it solves the problem!
However I still believe that changing the
prefixbehavior to be always displayed or making it configurable (maybe someapp:prefixAlwaysVisibleattribute) could be a good idea.Now, to show my area code correctly I had to use
setOnFocusChangeListenerand updatehintto empty string after gaining focus (otherwise bothprefixandhintwere visible on empty focused input).