2017-04-17 39 views
-3

有沒有人有一個想法如何在操作欄後面顯示錯誤消息?Android編輯文本錯誤重疊操作欄

enter image description here

請檢查這是設計的我的xml文件:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/activity_second" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context=".MainActivity" > 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 
    <EditText 
      android:id="@+id/editTextlastname" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:hint="lastname" 
      android:layout_marginTop="15dp" 
      android:paddingBottom="1000dp" 
      android:inputType="text"/> 

    </RelativeLayout> 
</ScrollView> 

+1

發表您的XML代碼 –

+1

如果您使用相對佈局,然後使用標籤>> 機器人:layout_below =「...」 –

+0

嘗試添加android:paddingTop =「?android:attr/actionBarSize」到父佈局 – Raghavendra

回答

0

我想你同時做所有的編輯文本的確認(在使用if塊||)逐個進行驗證(使用& &而不是||),它會自動將您的姓氏代碼聚焦在操作欄下面並顯示錯誤消息。

0

如果您使用RelativeLayout作爲您的主父佈局,請將其更改爲LinearLayout並將方向設置爲Vertical

0

我得到這個問題的解決方案,請嘗試這種

scrollView.setOnTouchListener(new View.OnTouchListener() { 
     @Override 
     public boolean onTouch(View v, MotionEvent event) { 
      if (yourEditText.getError() != null) { 
       yourEditText.setError(null); 
       return true; 
      } 
      return false; 
     } 
    });