2016-09-07 7 views
0

저는 두 가지 버전의 앱을 사용하고 있습니다. 첫 번째 버전에는 사용자가 데이터를 저장하려고 시도하고 행이 비어있는 경우 EditText UI 행에 설정된 setError 메시지가 있습니다. gradle dependencie는 버전 24.0.0을 사용합니다.Android :보기 왜곡을 일으키는 setError 메시지가 나타나는 이유는 무엇입니까?

메시지는 다음과 같이 올바르게 나타납니다

enter image description here

응용 프로그램의 두 번째 버전은 같은 setError 코드를 가지고 있지만 편집 텍스트 라인이보기로 푸시 다운 된 것처럼 보이기 때문에보기가 왜곡되지 그래서 더 이상 "Do"텍스트 바로 아래에없고 빨간색 원형 느낌표가 오류 메시지의 왼쪽으로 이동합니다. 이 버전은 gradle dependencie 버전 24.2.0을 사용합니다.

enter image description here

이 원인이 될 수 있는지에 어떤 아이디어?

을 아래

당 마이크 M의 코멘트, 내가 TextInputLayout에 setError()를 사용하지만 나는 오히려 사용하지하려는 글고 라인의 시작 부분 아래에 나타 완전히 다른 오류 메시지가 발생

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

가능한 [EditText 오류 아이콘 및 표시 암호가 잘못 배치되었습니다] (http://stackoverflow.com/questions/39313026/editext-error-icon-and-show-password-missplaced) –

+0

@Mike M. setError ()에서 느낌표 및 회색 오류 메시지 대화 상자가 사라집니다. 그것은 내가 사용하지 않는 EditText 줄 아래에 빨간색으로 메시지를 추가합니다. 그래서 EditText에서 setError()의 사용법을 수정하는 방법을 찾고 있습니다. – AJW

+0

gradle 종속 버전을 24.2.0에서 24.0.0으로 롤백했고 문제가 사라졌습니다. 아마도 새 종속성 버전에는 EditText와 함께 setError()를 올바르게 표시 할 수없는 버그가있을 수 있습니다. 이 문제를 테스트하기 위해 Google에 요청을 게시하는 것이 쉬운가요? – AJW

답변

1

this에 따르면 TextInputLayout 안에 EditText을 사용하면 24+ 이후에 이러한 종류의 동작이 발생합니다. 그래서 해결책은 바로 EditText을 사용하는 것입니다.

시도해보고 작동하는지 확인하십시오.