Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I display a dialog above the keyboard

Tags:

android

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

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

Thanks

Clark

like image 449
user1597721 Avatar asked Aug 30 '12 04:08

user1597721


2 Answers

Have you tried ths one?

Worked for me:

http://developer.android.com/reference/android/view/Window.html#setSoftInputMode(int).

alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
like image 186
Waza_Be Avatar answered Sep 22 '22 10:09

Waza_Be


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 ); 
like image 20
Oguz Ozcan Avatar answered Sep 20 '22 10:09

Oguz Ozcan