WinterChilly
WinterChilly

Reputation: 1599

TextInputLayout hint is too high

Is there any way to add padding to hint, when you click eddittext? I tried adding padding and margin in both edittext and TextInputLayout.

Currently:

  <android.support.design.widget.TextInputLayout
            android:id="@+id/login_layout_email"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="12dp"
            android:layout_marginEnd="36dp"
            android:layout_marginStart="36dp"
            android:background="@color/color_line_transparent"
            android:gravity="center"
            android:paddingEnd="16dp"
            android:paddingStart="16dp"
            android:theme="@style/TextLabel"
            app:errorTextAppearance="@style/TextAppearance.Design.Error">

            <EditText
                android:id="@+id/login_input_email"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_gravity="center"
                android:hint="@string/hint_email"
                android:inputType="textEmailAddress"
                android:textColor="@color/color_text_login"
                android:textSize="14sp" />

        </android.support.design.widget.TextInputLayout>

PRINTSCREEN Printscreen On Click

Upvotes: 1

Views: 1159

Answers (3)

Hussain
Hussain

Reputation: 91

You're setting the hint incorrectly, hint should be set on textinputlayout not edittext.

Upvotes: 0

w3bshark
w3bshark

Reputation: 2749

I haven't tried this, so I'm not sure if it works, but have you tried adding padding to the parent layout that's wrapping your TextInputLayout?

It looks like your TextInputLayout has the standard/default hint padding. So maybe you should go with trying to make the parent layout account for the large spacing between the hint of the TextInputLayout and the EditText views.

I wrote up a quick post on TextInputLayouts here, which may have some more tips that might help you out?: w3bshark.com/blog/input-layouts

Upvotes: 2

W4R10CK
W4R10CK

Reputation: 5550

Use padding in Edittext

  <android.support.design.widget.TextInputLayout
        android:id="@+id/login_layout_email"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="12dp"
        android:layout_marginEnd="36dp"
        android:layout_marginStart="36dp"
        android:background="@color/color_line_transparent"
        android:gravity="center"
        android:theme="@style/TextLabel"
        app:errorTextAppearance="@style/TextAppearance.Design.Error">

        <EditText
            android:id="@+id/login_input_email"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:paddingEnd="16dp"
            android:paddingStart="16dp"
            android:layout_gravity="center"
            android:hint="@string/hint_email"
            android:inputType="textEmailAddress"
            android:textColor="@color/color_text_login"
            android:textSize="14sp" />

  </android.support.design.widget.TextInputLayout>

Upvotes: 0

Related Questions