2014-04-02 69 views
2

我使用下面的代碼隱藏軟鍵盤從屏幕的Android關閉鍵盤順利

InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); 
     inputMethodManager.hideSoftInputFromWindow(
       mSearchView.getWindowToken(), 0); 

當鍵盤關閉一個白框出現在已經覆蓋它的一小段時間的空間,這可以避免嗎?

+0

你使用的是什麼版本的操作系統? – kAnNaN

+0

@kAnNaN我已經嘗試過android版本2.3至4.4 – pvn

+0

不確定,但在代碼後嘗試此行'overridePendingTransition(0,0);'。 – Kedarnath

回答

0

嘗試以下操作:

 InputMethodManager inputMethodManager = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE); 
     inputMethodManager.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0); 
+0

這並不能解決問題,軟鍵盤關閉時仍出現白色方塊 – pvn

0

的問題是,我已經設置windowSoftInputMode屬性adjustResize在清單中的活動。