material-components-android icon indicating copy to clipboard operation
material-components-android copied to clipboard

When I use TextInputLayout (whose hintEnabled is false and style is OutLinedBox ), it seems to be clipped

Open lysung opened this issue 8 years ago • 11 comments

When I use TextInputLayout (whose hintEnabled is false and style is OutLinedBox ), it seems to be clipped

Requirement

I want TextInputLayout's height is same as When it's hintEnabled is true, but don't show the lable(hint) on TextInputLayout, and the hint be shown in EditText

code in xml

<android.support.design.widget.TextInputLayout
        style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:hintEnabled="false"
        >
        <android.support.design.widget.TextInputEditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="12312312312"
            />
    </android.support.design.widget.TextInputLayout>

result

2018-07-31 8 47 44

it seems that the Input's bound clipped

result I want

2018-07-31 8 49 32

lysung avatar Jul 31 '18 01:07 lysung

Read https://material.io/develop/android/components/text-input-layout/

amiyo-biswas avatar Sep 04 '18 06:09 amiyo-biswas

@amiyo-biswas it doesn't work, I had already followed it

lysung avatar Sep 05 '18 07:09 lysung

Looking at the source code, the layout adds additional top margin if hintEnabled is true, else it completely ignores adding any top margin.

Don't know why they coded it like that, the top edge of the view is still there regardless if the hint is enabled or not. If that method (and the methods that call that method) weren't private, it'd be a simple fix to just ignore checking if hintEnabled is true or not, but those methods being private complicates things for us end-users.

nasahapps avatar Sep 05 '18 16:09 nasahapps

+1 Having this issue as well.

Cherubyx avatar Nov 22 '18 15:11 Cherubyx

In my case, if set hint for TextInputEditText programmatically then floating label not showing.

WaideShery avatar Nov 23 '18 15:11 WaideShery

This issue is being looked at with https://issuetracker.google.com/issues/111959880

ldjcmu avatar Nov 27 '18 15:11 ldjcmu

Also error text looses its top margin in this scenario

abhishekBansal avatar Dec 29 '18 13:12 abhishekBansal

Closing this issue, please follow https://issuetracker.google.com/issues/111959880 instead.

ikim24 avatar Jan 02 '19 22:01 ikim24

Looking at the source code, the layout adds additional top margin if hintEnabled is true, else it completely ignores adding any top margin.

Don't know why they coded it like that, the top edge of the view is still there regardless if the hint is enabled or not. If that method (and the methods that call that method) weren't private, it'd be a simple fix to just ignore checking if hintEnabled is true or not, but those methods being private complicates things for us end-users.

You saved my life! 4 years+, still wonder why Android development has to be this hard!

manideepl-dev avatar Dec 06 '19 10:12 manideepl-dev

if you have used app:hintEnabled="false" then also set android:paddingTop="8dp" in EditText and boom top hint space is gone, this worked for me hope this works for you too

AtulSalgaonkar avatar May 04 '20 14:05 AtulSalgaonkar

if you have used app:hintEnabled="false" then also set android:paddingTop="8dp" in EditText and boom top hint space is gone, this worked for me hope this works for you too

Wow thank you so much!

yashovardhan99 avatar Jul 20 '20 11:07 yashovardhan99