How to make edit text error position in android?

前端 未结 2 1630
傲寒
傲寒 2021-01-06 22:01

I have an app in which I have edit text fields in which I have to enter a mobile number and password. The problem is that the EditText error indicator covers th

相关标签:
2条回答
  • 2021-01-06 22:28

    @Nitin: Actually Edittext behaviour wants you to focus in the edittext to discard the seterror message to rectify the erroneous data and go to other fields.

    0 讨论(0)
  • 2021-01-06 22:31

    Use this android.support.design.widget.TextInputLayout. which can show the error below to the Edittext.so You can easily write next thing like your number and password in the new Edittext.

    Here is xml code :

    <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="match_parent"
            android:layout_marginTop="?attr/actionBarSize"
            android:orientation="vertical"
            android:paddingLeft="20dp"
            android:paddingRight="20dp"
            android:paddingTop="60dp">
    
            <android.support.design.widget.TextInputLayout
                android:id="@+id/input_layout_name"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">
    
                <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>
    
            <android.support.design.widget.TextInputLayout
                android:id="@+id/input_layout_email"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">
    
                <EditText
                    android:id="@+id/input_email"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:inputType="textEmailAddress"
                    android:hint="@string/hint_email" />
            </android.support.design.widget.TextInputLayout>
    
            <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:inputType="textPassword"
                    android:hint="@string/hint_password" />
            </android.support.design.widget.TextInputLayout>
    </LinearLayout>
    

    Let's see the ScreenShot for understand.

    Empty Edittext.

    Error message Edittext.

    0 讨论(0)
提交回复
热议问题