Adjusting size of custom dialog box in android

I'm not sure if this will work for your situation, but if you want to set it to full width or something similar, you need to get the current Window for the activity and set it's layout params like so:

myDialog.show();
Window window = myDialog.getWindow();
window.setLayout(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);

Edit

FILL_PARENT has been deprecated, use instead

window.setLayout(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);

You just need to add is style "Theme_AppCompat_Light_Dialog_Alert" to your dialog like this:

Dialog dialog = new Dialog(context, R.style.Theme_AppCompat_Light_Dialog_Alert);

and your dialog is looks like normal alert dialog

Tags:

Android