当输入法键盘显示的时候,弹出全屏弹框,这时默认情况下输入法键盘会消失,弹框会铺满整个屏幕,界面就会闪烁的效果,想让弹框弹出后输入法键盘不消失,输入法键盘盖在键盘上面,解决方法是修改弹框的window属性,Dialog的安卓官方文档有这样一段描述:
Note: Activities provide a facility to manage the creation, saving and restoring of dialogs. See Activity.onCreateDialog(int)
, Activity.onPrepareDialog(int, Dialog)
, Activity.showDialog(int)
, and Activity.dismissDialog(int)
. If these methods are used, getOwnerActivity()
will return the Activity that managed this dialog.
Often you will want to have a Dialog display on top of the current input method, because there is no reason for it to accept text. You can do this by setting the WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM
window flag (assuming your Dialog takes input focus, as it the default) with the following code:
getWindow().setFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM, WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
所以就是调用这段代码就可以。