Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove padding around alert dialog

I use AlertDialog.Builder to make a custom dialog using these instructions: http://developer.android.com/guide/topics/ui/dialogs.html#CustomDialog

It works, but my view is inside a black box (the standard dialog frame). This box has padding around its edges, so i cant make it use the full display width.

How can I get rid of the padding? I fetched the layoutparams after the dialog is displayed, and changed all the parameters and flags, nothing helped.

When someone else asked this here on SO, the answer was

builder.setView(dialogView, 0, 0, 0, 0);

but as far as I see, this method doesnt exist, only setView(dialogView).


2 Answers

It's not builder.setView You need to create an instance of the dialog first:

Dialog dialog = builder.create();
dialog.setView(dialogView, 0, 0, 0, 0);
like image 73
npace Avatar answered Oct 28 '25 23:10

npace


I believe the only way to do this is to use the base (or extended) Dialog class and setView to set a custom view.

You'll also have to add your own buttons and handle them accordingly.

like image 40
Austin Hanson Avatar answered Oct 28 '25 23:10

Austin Hanson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!