Search code examples
androidandroid-edittexttextinputlayout

Gap between Edittext underline and Hint in Input Layout


I am using EditText Input layout.

Below is my xml code :

<android.support.design.widget.TextInputLayout
        android:id="@+id/TextInputLayout1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <EditText
            android:id="@+id/et_edittext"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Enter Password"
            android:imeOptions="actionNext"
            android:maxLines="1"
            android:inputType="text" />

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

I want to give more gap between the editText underline and the hint text(Enter Password). And I want to reduce the size of the hint text.

Can anyone please help me how to get this.

enter image description here


Solution

  • Try with below code : Use android:padding="any value in sp/dp" for between your bottom line and editText.

     <android.support.design.widget.TextInputLayout
        android:id="@+id/TextInputLayout1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginEnd="8dp"
        android:layout_marginStart="16dp"
        android:layout_marginTop="8dp"
        android:clipChildren="false">
    
        <android.support.design.widget.TextInputEditText
            android:id="@+id/password_et"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_margin="3dp"
            android:hint="Password"
            android:padding="5dp"
            android:translationY="3dp" />
    </android.support.design.widget.TextInputLayout>