【问题标题】:AlertDialog overlaps custom keyboard in androidAlertDialog 与 android 中的自定义键盘重叠
【发布时间】:2018-02-01 16:19:08
【问题描述】:

我正在尝试使用滚动视图创建一个对话框,该对话框从我的自定义键盘的键单击事件中显示。以下是代码sn-p。对话框警报与键盘重叠。有没有办法让它保持在键盘上方?

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();

【问题讨论】:

    标签: android keyboard android-alertdialog ime


    【解决方案1】:

    你可以试试setSoftInputMode

    指定用于窗口的显式软输入模式,根据 WindowManager.LayoutParams.softInputMode。提供除此之外的任何东西 此处的“未指定”将覆盖窗口的输入模式 通常从其主题中检索。

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

    【讨论】:

    • @Nikki 设置你的清单部分android:windowSoftInputMode="adjustPan"
    • @Amiya 也没有帮助。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-04
    • 1970-01-01
    • 2013-01-18
    • 2019-01-20
    • 2013-03-14
    相关资源
    最近更新 更多