简体   繁体   中英

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 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!

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...

在为对话框提供自定义布局时,您应该仅能像往常一样在文本周围提供顶部和底部填充。

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM