简体   繁体   English

AlertDialog与android中的自定义键盘重叠

[英]AlertDialog overlaps custom keyboard in android

I am trying to create a dialog with scrollview, which is shown from key click event of my custom keyboard. 我正在尝试创建一个带有scrollview的对话框,该对话框从我的自定义键盘的按键单击事件中显示。 Following is the code snippet. 以下是代码段。 The dialog alert overlaps the keyboard. 对话框警报与键盘重叠。 Is there anyway to keep it above the keyboard ? 无论如何,可以将其保持在键盘上方吗?

AlertDialog dialog;
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            dialog = builder
                    .setPositiveButton("ok", null)
                    .setView(mView)
                    .create();
            Window window = dialog.getWindow();
            WindowManager.LayoutParams lp = window.getAttributes();
            lp.token = mInputView.getWindowToken();
            lp.type = WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG;
            window.setAttributes(lp);
            window.addFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
            dialog.show();

You can try with setSoftInputMode 您可以尝试使用setSoftInputMode

Specify an explicit soft input mode to use for the window, as per WindowManager.LayoutParams.softInputMode. 根据WindowManager.LayoutParams.softInputMode,指定要用于窗口的显式软输入模式。 Providing anything besides "unspecified" here will override the input mode the window would normally retrieve from its theme. 在此处提供“未指定”以外的任何内容都将覆盖窗口通常从其主题检索的输入模式。

......
dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
dialog.show();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM