android: how to resize dialog
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 follow开发者_运维技巧ing way:
alt text http://img199.imageshack.us/img199/1299/popupstackoverflow.png
Does anyone know how to make the dialog bigger (extend height)?
Thank you!
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...
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.
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?
精彩评论