Material-components-android: Suffix/prefix for TextInputLayout is visible only when the view is focused

Created on 3 Jul 2020  路  5Comments  路  Source: material-components/material-components-android

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.

feature request

Most helpful comment

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).

All 5 comments

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?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mnayef95 picture mnayef95  路  3Comments

JakeWharton picture JakeWharton  路  3Comments

ahmaducg picture ahmaducg  路  3Comments

JavierSegoviaCordoba picture JavierSegoviaCordoba  路  3Comments

ataulm picture ataulm  路  3Comments