[TextInputLayout] Allow hint to float always
See original GitHub issueIs your feature request related to a problem? Please describe. Currently it is impossible to set a hint to both TextInputLayout and TextInputEditText without both overlapping, in some cases it would be nice to show both hints to the user.
Describe the solution you’d like Create an attribute such as:
android:hintAlwaysFloat="true"
Or something like it.
Describe alternatives you’ve considered The easiest alternative to achieve such design is to set a TextView and an EditText within a container and handle both of them.
I’ve also seen the use of reflection to achieve such behaviour, however this brings undesired problems.
Additional context Actual:
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Name">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="e. g. Mauro N."
android:inputType="text"/>
</com.google.android.material.textfield.TextInputLayout>
Suggested:
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Name"
android:hintAlwaysFloat="true">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="e. g. Mauro N."
android:inputType="text"/>
</com.google.android.material.textfield.TextInputLayout>
Issue Analytics
- State:
- Created 4 years ago
- Reactions:19
- Comments:8 (4 by maintainers)
Top Results From Across the Web
android - Keep Textinputlayout hint always top - Stack Overflow
Here's a hack - programmatically add a space in the text if it's empty. However, you would then have to remove the space...
Read more >TextInputLayout | Android Developers
Layout which wraps a TextInputEditText , EditText , or descendant to show a floating label when the hint is hidden while the user...
Read more >Android TextInputLayout Example | DigitalOcean
Floating Hints are enabled by default in a TextInputLayout. To disable it we need to add the following attribute inside the tag :...
Read more >Floating Labels In EditText TextInputLayout Android
It takes the value of hint assigned to EditText and displays it as floating label. Android Design Support Library introduced some important new...
Read more >TextInputLayout hint does not support Span [37076105]
textInputLayout.setHint(hint); TextInputLayout uses internal class CollapsingTextHelper to draw the hint, which does not support spans.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We added support for this in https://github.com/material-components/material-components-android/commit/22973ff10305397bfc72fed41684175fee8aeefb via the new
expandedHintEnabled
attribute, available in version1.3.0-alpha03
.Afaict, placeholderText only shows both when selected, which is bot what you want. https://github.com/material-components/material-components-android/pull/1163 contains a proper (and trivial) fix to make hints always work as desired.