1
我面臨和我的一個有點複雜片段佈局XML的情況下,背景干擾
所以層次如下爲:
RelativeLayout的(無背景)
--ScrollView(fillViewPort =真,滾動條=無)
----的FrameLayout(無背景)
------的LinearLayout(無背景)
-------- RelativeLayout的(灰色背景顏色)
---------- EditText
...
所以,當點擊的EditText它打開軟鍵盤(如預期),而當背壓或隱藏鍵盤下面的方法一定點擊塊:
try {
InputMethodManager inputMethodManager = (InputMethodManager) GlobalApplication.getInstance().getCurrentActivity().getSystemService(Activity.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(GlobalApplication.getInstance().getCurrentActivity().getCurrentFocus().getWindowToken(), 0);
} catch (Exception e) {
if (e.getMessage() != null)
Log.d("KeyboardError", e.getMessage());
}
的問題是我」對於活動有紅色背景,當隱藏鍵盤動作發生時,我看到活動的背景,而不是RelativeLayout的灰色背景,並且發生像是毛刺或卡住。一段時間後,它恢復正常,並顯示適當的背景。
感謝您的幫助,歡呼聲。
指定要使用的Android版本。這將有助於找到答案 – The4thIceman
它發生在幾個版本的Android 4.4.2 5.1 6.0 7.0 –