[TextInputLayout] TextInputLayout falls down 12dp when hintEnabled is set to "false"
See original GitHub issueDescription: The TextInputLayout
falls down 12dp
when floating label is disabled using app:hintEnabled="false"
and when placed in a LinearLayout.
Screenshot -
Expected behavior: TextInputLayout
on the left has Floating Label disabled by using app:hintEnabled=false
and TextInputLayout
on the right has Floating Label Enabled.
The left one falls down, when it should not and stay aligned with the right one.
Error is enabled in both the Fields.
Source code:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox"
android:layout_width="200dp"
android:layout_height="wrap_content"
app:errorEnabled="true"
app:hintEnabled="false" >
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Floating Label/Hint Disabled" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox"
android:layout_width="200dp"
android:layout_height="wrap_content"
app:errorEnabled="true"
android:hint="Floating Label/Hint Enabled" >
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
Android API version: 28
Material Library version: implementation 'com.google.android.material:material:1.1.0'
Device: Android Studio Preview Window and Redmi 4X (India)
Workaround: If I offset the top margin by 12 dp - android:marginTop="-12dp"
, it aligns with right one.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Disable/Remove floating label hint text in TextInputLayout XML
Starting version 23.2.0 of the Support Library you can call setHintEnabled(false). or putting it in your TextInputLayout xml as such :
Read more >TextInputLayout | Android Developers
Returns the text color used by the hint in both the collapsed and expanded states, or null if no color has been set....
Read more >TextInputLayout (Floating Label EditText) - Android Studio ...
In this video we will learn, how to use the TextInputLayout together with the TextInputEditText widget, to create an EditText with advanced ...
Read more >While Using A Material.Textfield.Textinputlayout, My Outlined ...
Description: The TextInputLayout falls down 12dp when floating label is disabled using app:hintEnabledfalse and when placed in a LinearLayout. Screenshot.
Read more >Android TextInputLayout Example | DigitalOcean
To disable it we need to add the following attribute inside the tag : app:hintEnabled="false" . The below xml code is from the...
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
Does it look better if you set
android:baselineAligned="false"
to the linearlayout?I think it’s a duplicate of #1113. Let’s close this one and move the discussion there to better track the issue.