Pradeep Gupta
Pradeep Gupta

Reputation: 1770

How to change the floating label position of TextInputLayout centre horizontal

I want the floating label position to be centre align. I searched a lot but didn't get any solution.

Please help me.

Upvotes: 3

Views: 2058

Answers (3)

D Agrawal
D Agrawal

Reputation: 471

Try this:

 <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:gravity="center"
            />

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

Upvotes: 2

Xose Sanchez
Xose Sanchez

Reputation: 318

Set the align on the gravity, on android:gravity="center_horizontal". So it could be:

    <EditText
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/editText"
    android:gravity="center_horizontal"
    android:hint="your hint" />

Hope this helps.

Upvotes: 0

Lokanath
Lokanath

Reputation: 682

Hi have you tried setting textAlignment and gravity properties...give them a try

<android.support.design.widget.TextInputLayout
        android:id="@+id/input_layout_name"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:textAlignment="center">

        <EditText
            android:id="@+id/input_name"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:singleLine="true"
            android:hint="@string/hint_name" />
    </android.support.design.widget.TextInputLayout>

hope this helps..

Upvotes: 0

Related Questions