Reputation: 313
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
Upvotes: 8
Views: 17809
Reputation: 331
AlertDialog dialog = new AlertDialog.Builder(this).create();
dialog.show();
Window window = dialog.getWindow();
window.clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
Upvotes: 1
Reputation: 41
create a Xml file name style.xml
<style name="FullHeightDialog" parent="android:style/Theme.Dialog">
<item name="android:windowNoTitle">true</item>
<item name="android:windowSoftInputMode">stateUnchanged</item>
<item name="android:windowBackground">@color/dialog_transparent</item>
</style>
then Implement
this works for me hoping it will work for you also.
final Dialog dialog = new Dialog(this , R.style.FullHeightDialog);
and also do changes in your manifest file
android:windowSoftInputMode="adjustResize|adjustPan"
Upvotes: 3
Reputation: 1714
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 );
Upvotes: 9
Reputation: 39564
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);
Upvotes: 30