Android: why does setError message cause distortion?

I have two versions of the application I'm working on. The first version has a setError message, which is set in the EditText interface line if the user is trying to save data and the line is empty. gradle dependencie uses version 24.0.0.

The message is displayed correctly:

enter image description here

The second version of the application has the same setError code, but the view looks distorted because it looks like the "Edit Text" line has been shifted down, so it is no longer directly below the "Do" text and with a red circular exclamation point moves down to the left of the message about an error. This version uses the dependency version of gradle 24.2.0.

enter image description here

Any ideas on what could be causing this?

Regarding Mike M, below I used setError () in a TextInputLayout, but this leads to a completely different error message that appears below the start of the EditText line that I would not use:

enter image description here

Activity.java

... public void onClickSave(View v) { int stringTD = EditText.getText().toString().replace(" ", "").length(); if (stringTD == 0) { EditText.requestFocus(); EditText.setError("Add a Do Item"); 

layout.xml

 ... <android.support.design.widget.TextInputLayout android:id="@+id/TD_text_input_layout" android:layout_width="match_parent" android:layout_height="wrap_content" android:textColorHint="@color/colorFlLabelFinal" app:hintTextAppearance="@style/FloatingLabel" > <com.EditText android:id="@+id/EditText" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingTop="2dp" android:inputType="text|textCapSentences|textNoSuggestions" android:textAppearance="?android:attr/textAppearanceLarge" android:textColor="#FFFFFF" android:textIsSelectable="true" android:textColorHighlight="@color/colorPrimary" android:paddingLeft="5dp" android:paddingStart="5dp" android:drawableStart="@drawable/24dp" android:drawableLeft="@drawable/24dp" android:drawablePadding="5dp" android:maxLines="1" android:maxLength="51" android:imeOptions="actionNext|flagNoExtractUi" android:nextFocusDown="@+id/DEditText" /> 
0
source share
1 answer

According to this , if you use EditText inside a TextInputLayout , this type of behavior occurs after version 24+. So the solution right now will be to use only EditText .

Try it and see if it works.

+1
source

All Articles