简体   繁体   English

当edittext在软键盘后面时,在android对话框上调整平移

[英]Adjusting pan on android dialog when edittext is behind the soft keyboard

So I have this piece of coding that I can't get to work: I have searched on the webs, and always found the same answer, but for some reason it just won't work. 因此,我有一段无法使用的编码:我在网上搜索,总是找到相同的答案,但是由于某种原因,它将无法正常工作。 Any idea why? 知道为什么吗? This is my code: 这是我的代码:

    final Dialog dialog = new Dialog(RegisterActivity.this);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
    dialog.setContentView(R.layout.dialog_register_info_1);
    dialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    dialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL, WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);

I have tried putting the dialog.getWindow().setSoftInputMode() behind the setContentView() too, but that didn't work either. 我也尝试将dialog.getWindow().setSoftInputMode()放在setContentView()后面,但是那也不起作用。 The dialog only has a .xml file, so no activity. 该对话框只有一个.xml文件,因此没有活动。

Thanks in advance 提前致谢

I'm not sure if this is what you were looking for, but I wanted the dialog to appear above the keyboard and not behind it. 我不确定这是否是您要查找的内容,但我希望对话框显示在键盘上方而不是键盘下方。 What I did was this: 我所做的是:

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

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

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