Skip to content Skip to sidebar Skip to footer

How To Make Edit Text Error Position In Android?

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 the mobile number and

Solution 1:

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 :

<LinearLayoutandroid: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.TextInputLayoutandroid:id="@+id/input_layout_name"android:layout_width="match_parent"android:layout_height="wrap_content"><EditTextandroid: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.TextInputLayoutandroid:id="@+id/input_layout_email"android:layout_width="match_parent"android:layout_height="wrap_content"><EditTextandroid: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.TextInputLayoutandroid:id="@+id/input_layout_password"android:layout_width="match_parent"android:layout_height="wrap_content"><EditTextandroid: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.

enter image description here

Error message Edittext.

enter image description here

Solution 2:

@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.

Post a Comment for "How To Make Edit Text Error Position In Android?"