material-components / material-components-android

Modular and customizable Material Design UI components for Android
Apache License 2.0
16.33k stars 3.06k forks source link

[TextInputLayout] Allow to place label above the outline box #2270

Closed sabinebarrera closed 2 years ago

sabinebarrera commented 3 years ago

**Is your feature request related to a problem? Yes. Field aliases in a database table can has a long text. This long name get ellipsized but there is no option to specify if you want the label for outline TextInputLayout` to be above the box.

Describe the solution you'd like Provide style for floating labels: XML attribute(s) and setter/getter (s).

Describe alternatives you've considered Adding a textView above the TextInputLayout but we don't want to deviate from what it is provided by the Android API. It is an overkill and it should be supported.

Additional context This is the design we are trying to achieve.

Design Artboard

Screens below show the comparison between our iOS vs Android app:

Implementation Screens | iOS | Android | | --- | --- | | | | | Check marks show the UI piece for the field alias name | X show the UI piece for the field alias name that is ellipsized |
drchen commented 3 years ago

Can't it be easily done by wrapping TextInputLayout in another layout?

Can you provide more use cases so we can evaluate if this is a valuable feature to add?

sabinebarrera commented 3 years ago

@drchen yes, you could wrapped a MaterialTextView and TextInputLayout within ConstraintLayout but is this efficient? the TextInputLayout already has this label. As shown in the images I shared above, the use case is when you have a form fields (with many of those) that the user needs to fill when collecting data on the field.

drchen commented 2 years ago

It won't be less efficient than whatever approaches we may need to adopt on the library side.

The existing label behavior is kind of complicated - it collapses and expands according to the focus state. I will be hard to support more flexible positioning of it, and, more importantly, it's not the design intention of it.

Since clients can easily do this on their own, and it's not part of the Material design. I'll close the issue as no-go.