question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[TextInputLayout] TextInputLayout falls down 12dp when hintEnabled is set to "false"

See original GitHub issue

Description: The TextInputLayout falls down 12dp when floating label is disabled using app:hintEnabled="false" and when placed in a LinearLayout.

Screenshot - image

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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
ymariancommented, Jun 24, 2020

Does it look better if you set android:baselineAligned="false" to the linearlayout?

0reactions
drchencommented, Apr 15, 2022

I think it’s a duplicate of #1113. Let’s close this one and move the discussion there to better track the issue.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found