2015-07-21 89 views
5

我有一個TextInputLayout的佈局,裏面有EditTextTextInputLayout自動對焦

加載佈局時,EditText立即處於編輯模式,鍵盤沒有彈起,但光標閃爍,提示不在EditText之內,但在其上方。

我想讓提示動畫出EditText,只有使用第一次點擊EditText

我該如何做到這一點?我在EditTextTextInputLayout上嘗試了clearFocus()。

我的XML:

<android.support.design.widget.TextInputLayout 
      android:id="@+id/textInputLayout" 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_weight="1"> 

      <EditText 
       android:singleLine="true" 
       android:id="@+id/case_name" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:hint="Case name" > 
       </EditText> 

     </android.support.design.widget.TextInputLayout> 
+1

@Kuffs機器人:windowSoftInputMode = 「stateHidden」 也不管用,歡迎您來嘗試。 – aviran

+0

也許我提出的問題並不是一個好例子,但也有很多其他人問同樣的問題。請使用搜索。 http://stackoverflow.com/questions/5550429/edittext-android-automatic-focus檢查所有答案不只是接受的答案。 – Kuffs

+0

這一個最有活性http://stackoverflow.com/questions/1555109/stop-edittext-from-gaining-focus-at-activity-startup – Kuffs

回答

-1

試試這個

editText.setCursorVisible(false) 
+0

隱藏光標,但焦點仍然在EditText上,這意味着不顯示提示。 – aviran

+0

你能告訴我你的EditText嗎? –

+0

當然,我已經編輯了問題 – aviran