2

내 도구 모음에서 EditText보기를 사용하고 "확인"아이콘을 클릭하면 모든 필드가 비어 있는지 확인합니다. if가 비어 있으면 setError() 메서드가 호출됩니다. 그러나 팝업 메시지는 이상하게 보입니다 (아래 그림 참조). enter image description hereEditText.setError()의 팝업 메시지 레이아웃이 이상하게 보입니다.

부드러운 입력을 숨기면 다음과 같이 보입니다. enter image description here

또 다른 문제는 EditText보기는 루트 레이아웃에 있는지, 그리고 setError()가 호출 될 때, 뷰가 자동으로 (Appbarlayout이 숨겨져)를 스크롤. 레이아웃이 뷰 아래에 정확하게 있도록하는 방법은 무엇입니까? enter image description here

레이아웃 디자인의 문제점입니까?

layout.xml

<?xml version="1.0" encoding="utf-8"?> 
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 

    <android.support.design.widget.AppBarLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     > 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/tool_bar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:minHeight="?attr/actionBarSize" 
      android:theme="@style/ActionbarStyle" 
      app:layout_scrollFlags="scroll|enterAlways|snap"> 

      <EditText 
       android:id="@+id/et_ItemName" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:hint="@string/item_name" 
       android:inputType="text|textAutoCorrect" 
       android:maxLength="20" 
       android:textStyle="bold"> 

       <requestFocus /> 
      </EditText> 
     </android.support.v7.widget.Toolbar> 
    </android.support.design.widget.AppBarLayout> 

    <android.support.v4.widget.NestedScrollView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:paddingBottom="@dimen/layout_padding" 
     android:paddingLeft="@dimen/layout_padding" 
     android:paddingRight="@dimen/layout_padding" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:orientation="vertical"> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:orientation="horizontal"> 

       <ImageView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_gravity="center_vertical" 
        app:srcCompat="@drawable/ic_money_black_24dp" /> 

       <EditText 
        android:id="@+id/et_Dollar" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_gravity="center_vertical" 
        android:gravity="end|right" 
        android:inputType="numberDecimal" 
        android:textStyle="bold" /> 
      </LinearLayout> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:orientation="horizontal"> 

       <ImageView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_gravity="center_vertical" 
        app:srcCompat="@drawable/ic_sort_black_24dp" /> 

       <Button 
        android:id="@+id/btn_SelectCategory" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:background="?attr/selectableItemBackground" 
        android:clickable="true" 
        android:gravity="end|right|center_vertical" 
        android:hint="@string/select_category" /> 
      </LinearLayout> 

      <EditText 
       android:id="@+id/et_Note" 
       android:layout_width="match_parent" 
       android:layout_height="0dp" 
       android:layout_weight="1" 
       android:background="@drawable/background_border" 
       android:gravity="top|left" 
       android:hint="@string/note" 
       android:inputType="textMultiLine" 
       android:minLines="1" 
       android:padding="@dimen/TextPAdding" /> 

      <include 
       android:id="@+id/view_image_container" 
       layout="@layout/layout_add_photo" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:layout_marginTop="@dimen/widget_padding" /> 

     </LinearLayout> 
    </android.support.v4.widget.NestedScrollView> 

</android.support.design.widget.CoordinatorLayout> 
+0

테스트 사례 제거''시도 –

답변

0
  • 유 시간의 특정 기간 동안 적절한 메시지를 보여줄 수있는 당신은 훨씬 더 보이는 검증으로 플로팅 작업을 사용하고 사용자 정의를 가질 수 ... 예 : textChangedListener에 또는 버튼을 클릭 ->

    submitBT = (Button) findViewById(R.id.submitBT); 
    
         submitBT.setOnClickListener(new View.OnClickListener() { 
          @Override 
          public void onClick(View v) { 
           if (loginET.getText().toString().isEmpty() || loginET.length() == 0 || loginET.length() > 50) { 
          Snackbar.make(view, "Please Enter Username/Email", Snackbar.LENGTH_SHORT).show(); 
          return; 
         } 
         if (passwordET.getText().toString().isEmpty() || passwordET.length() == 0 || passwordET.length() > 50) { 
          Snackbar.make(view, "Password", Snackbar.LENGTH_SHORT).show(); 
         } 
          } 
         }); 
    

    당신은 또한 textChangedListener ... 그리고 VI에 사용할 수있는 ew가 seterror처럼 자동으로 스크롤되지 않음

관련 문제