0

enter image description here

This is my xml code to make a input text for user phone number but when it unfocused the hint label showed with larger text size my question is how to make the hint label activated like password even when there is no text in the field.

<android.support.design.widget.TextInputLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textColorHint="@color/colorText">

            <android.support.design.widget.TextInputEditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="@string/phone_number"
                android:inputType="number"
                android:maxLines="1"
                android:textColorHint="@color/colorText" />

        </android.support.design.widget.TextInputLayout>
Abanoub Samaan
  • 226
  • 1
  • 5
  • 11
  • Have you thought of using an edit text and text view to achieve your desired view instead of TextInputLayout? I don't think you need Text Input Layout, good old edit text and text view is enough. – Srikar Reddy Dec 04 '16 at 12:07
  • I know that I can do this solution but I want to use TextInputEditText. – Abanoub Samaan Dec 04 '16 at 13:08

1 Answers1

2

Your hint is in the wrong place

<android.support.design.widget.TextInputLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="@string/phone_number"
    android:textColorHint="@color/colorText">

    <android.support.design.widget.TextInputEditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="number"
        android:maxLines="1"
        android:textColorHint="@color/colorText" />

</android.support.design.widget.TextInputLayout>
Abhimanyu
  • 11,351
  • 7
  • 51
  • 121
Axel López
  • 266
  • 1
  • 5
  • 13