1

I would like to create a dialog-style form which would fill the bigger screen area (left, right, top, bottom padding 10px).

I defined the style "CupCakeDialog" the following way:

<style name="CupcakeDialog" parent="android:Theme.Dialog">
    <item name="android:windowAnimationStyle">@null</item>
</style>

and by running the activity:

getWindow().requestFeature(Window.FEATURE_PROGRESS);
getWindow().requestFeature(Window.FEATURE_NO_TITLE);

setContentView(R.layout.ad_popup);

The dialog is displayed the following way:

alt text http://img199.imageshack.us/img199/1299/popupstackoverflow.png

Does anyone know how to make the dialog bigger (extend height)?

Thank you!

Niko Gamulin
  • 66,025
  • 95
  • 221
  • 286

3 Answers3

18

Yes, I am late, but the answer is here.

dialog.show();

Display display =((WindowManager)getSystemService(context.WINDOW_SERVICE)).getDefaultDisplay();
    int width = display.getWidth();
    int height=display.getHeight();

    Log.v("width", width+"");
dialog.getWindow().setLayout((6*width)/7,(4*height)/5);

Change height or width, whatever is needed...

dandan78
  • 13,328
  • 13
  • 64
  • 78
Shahzad Imam
  • 2,030
  • 2
  • 26
  • 45
1

As you're providing a custom layout for the dialog, you should just be able to provide top and bottom padding as normal around the text.

Christopher Orr
  • 110,418
  • 27
  • 198
  • 193
1

For Dialogs/AlertDialogs inside a DialogFragment, you should resize the window in DialogFragment.onStart(); especially if using AppCompat support library 23.2.1 or 24 or above.

See here for example: How to resize an AlertDialog.Builder?

Mr-IDE
  • 7,051
  • 1
  • 53
  • 59