可以在AndroidManifest.xml文件中为活动添加android:windowSoftInputMode属性,该属性具有值“adjustPan”或“adjustNothing”,以控制软键盘的调整。例如,在活动标记中添加以下行:。对于MaterialAlertDialogBuilder,可以通过设置AlertDialog对象的窗口的软输入模式来完成同样的操作。例如:
AlertDialog dialog = builder.create(); dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
上一篇:避免键盘打开时屏幕被推到状态栏上方。
下一篇:避免键盘在AndroidStudio中改变MaterialAlertDialogBuilder的大小