如何在键盘上方显示对话框 [英] How can I display a dialog above the keyboard

查看:104
本文介绍了如何在键盘上方显示对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是android的新手,我编写了一个应用程序,当用户选择一件事时,该对话框使用Dialog来显示数据.对话框的外观如下:

I'm a newbie with android, I write an application which using the Dialog to display data when user select on one thing. This is how the dialog looks:

https://docs.google.com/file/d/0B3NUAgD0tB0YOS16azFCWXdSVVE/edit

但是当我点击最后一个EditText输入一些数据时,对话框仍然显示,当我键入第一个字符时,对话框会向下滚动.对话框留在键盘后面,某些部分完全被遮盖住了.

But when I tap on the last EditText to enter some data, the dialog still shows, when I type the first character, the dialog scrolls down. The dialog stays behind the keyboard, with some parts totally obscured.

有人可以告诉我如何在软键盘上方显示整个对话框吗?这就是我想要的样子:

Could anyone tell me how to show the whole dialog above the soft keyboard? This is how I'd like it to look:

https://docs.google.com/file/d/0B3NUAgD0tB0YOFVQYUF0U0JvOEk/edit

谢谢

克拉克

推荐答案

您可能需要手动设置对话框的宽度和高度,以使软输入模式像这样工作:

You may need to set dialog's width and height manually in order to make soft input mode work like this:

    WindowManager.LayoutParams params = window.getAttributes();
    params.width = WindowManager.LayoutParams.MATCH_PARENT;
    params.height = WindowManager.LayoutParams.MATCH_PARENT;
    params.gravity = Gravity.CENTER;
    window.setAttributes(params); 
    window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE ); 

这篇关于如何在键盘上方显示对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆