How to Change the Floating Label position of TextInputLayout in android

Baqir picture Baqir · Oct 27, 2015 · Viewed 11.1k times · Source

I have a rectangular shaped Edit Text which is inside the TextInputLayout. I want to put some margin between floating label and rectangular boundaries of edit text but i am not able to do that. I tried different margins parameters but it didn't workout. here is the screen shot of the Edit text

In the image you can see that floating label is stick with the upper boundary of the rectangular edit text. But i want some space between label and upper boundary. Thanx in advance.

below is the XML code for EditText

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

           >

            <EditText
                android:id="@+id/input_password"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="email"

                android:background="@drawable/textbg"/>

below is the code for background drawable

<shape xmlns:android="http://schemas.android.com/apk/res/android"

    android:shape="rectangle">
    <stroke android:width="1dp"
        android:color="@color/colorPrimary"/>
    />

    <padding
        android:left="15dp"
        android:right="15dp"
        android:top="15dp"
        android:bottom="15dp" />
</shape>

Answer

kirti picture kirti · Oct 26, 2016

You can give the height manually to TextInputLayout Like :

android:layout_height="100dp"

it work for me.