1EditText初始不彈出軟鍵盤,只有游標顯示,點選再彈出;2android:imeOptions
阿新 • • 發佈:2019-02-04
部落格時間:2013-06-08 10:13
剛進來的時候,不彈出鍵盤,EditText 有個游標上面閃,證明是可編輯的,這個還是符合使用者習慣的,從使用者體驗的角度上講,還保留游標的閃動是好的。
解決方法1:(已經試過,證明可以)
在activity屬性中設定 android:windowSoftInputMode="stateHidden"解決方法2:
InputMethodManager inputMethodManager = (InputMethodManager)this.getSystemService(Context.INPUT_METHOD_SERVICE); inputMethodManager.hideSoftInputFromWindow(et.getWindowToken(), 0);解決方法3:
---------------------------------------------------------------------------------------------------
當點選EditText的時候會自動彈出輸入法鍵盤,或者直接呼叫editText.requestFocus()使顯示輸入法鍵盤,
其中android:imeOptions指定了彈出鍵盤時右下角的按鍵的顯示文字,未指定時預設為回車圖示。
android:imeOptions="flagNoExtractUi" //使軟鍵盤不全屏顯示,只佔用一部分螢幕
同時,這個屬性還能控制元件軟鍵盤右下角按鍵的顯示內容,預設情況下為回車鍵
android:imeOptions="actionNone" //輸入框右側不帶任何提示
android:imeOptions="actionGo" //右下角按鍵內容為'開始'
android:imeOptions="actionSearch" //右下角按鍵為放大鏡圖片,搜尋
android:imeOptions="actionSend" //右下角按鍵內容為'傳送'
android:imeOptions="actionNext" //右下角按鍵內容為'下一步'
android:imeOptions="actionDone" //右下角按鍵內容為'完成'