2

I am having a dialog in which a few fields are shown. The dialog fills the whole screen. But it is not being adjusted or resized when key pad is raised.

Please see this image,

enter image description here

I have specified in my code as well as in style.xml file but of no use. How to adjust the pan with the keypad? User will be frustrated if this is the case.

This is my code,

  final Dialog dialog = new Dialog(this,R.style.Theme_MyDialog);
    dialog.setTitle("Enter Details");
   dialog.setContentView(view);
 dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
    dialog.show();

This is my style.xml code,

 <style name="Theme.MyDialog" parent="@android:style/Theme.Dialog">
    <item name="android:windowSoftInputMode">adjustResize|adjustPan</item>
 </style>

Please help me in solving this. Thanks for any help!!

Mahe
  • 2,707
  • 13
  • 50
  • 69

1 Answers1

0

'adjustPan' should not be used in style.xml and the height of contentView should not use precise size. The following code may be used:

    Window window = getWindow();
    WindowManager.LayoutParams params = window.getAttributes();

    // set width,height by density and gravity
    float density = getDensity(context);
    params.width = (int) (width * density);
    params.height = LayoutParams.FILL_PARENT;
    params.gravity = Gravity.CENTER;
    window.setAttributes(params);