[TextInputLayout] gravity "top" is not working for hint
See original GitHub issueDescription:
Prerequisite: TextInputLayout
with TextInputEditText
having hint
attribute
Migrated a layout having design TextInputEditText
to material.textfield.TextInputLayout
but it is not placing the hint at the top though it was working with support.design.widget
and also working for text
but not for hint
attribute.
Expected behavior:
Content
hint is placed at the top, see in pic
Minimal Problematic source code:
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/txtInput"
app:layout_constraintTop_toTopOf="parent"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/et_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="top"
android:hint="@string/et_content_text" />
</com.google.android.material.textfield.TextInputLayout>
Android API version: 29
Material Library version: com.google.android.material:material:1.2.0-alpha04
Device: Pixel 2 (AVD)
Note: I’ve tested this with alpha04 release, still the same issue
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:10 (1 by maintainers)
Top Results From Across the Web
How to set different gravity for TextInputLayout's hint and text ...
To set a different gravity for the EditText , don't set any gravity attributes in the layout, then set the EditText 's gravity...
Read more >TextInputLayout does not work correctly on multi-line EditText ...
Hint text is not initially visible - Hint text is always vertically centered instead of respecting gravity (gravity=top should display hint text at...
Read more >TextInputLayout | Android Developers
Returns whether the hint expands to occupy the input area when the text field is unpopulated and not focused. boolean, isHelperTextEnabled().
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 >TextInputEditText how can align hint to the top margin - Reddit
Why ? Instead i'm not encounter this problem with com.google.android.material:material:1.1.0-beta02. This is my ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
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
For the filled text field style you have to set
android:minLines
to 2 or greater for it to work (along withandroid:gravity="top"
)@ikim24 Still now working for me…
Android API version: 29
Material Library version: com.google.android.material:material:1.2.0-alpha05
If it helps, setting the TextInputLayout’s attribute hintEnabled=false does put the EditText to the top, but then I am missing the collapsed hint 😕