Android get full width for custom Dialog

You need to get the current Window and set it’s LayoutParams like so:

Dialog d=new Dialog(mContext);
.........
.........
myDialog.show();
Window window = myDialog.getWindow();
window.setLayout(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);

Alternative(if above solution does’t works)

In case above code not works well you can use a workaround

styles.xml

<style name="mydialog"></style>

Java

Dialog d=new Dialog(mContext,R.style.mydialog);
.........
.........
myDialog.show();
Window window = myDialog.getWindow();
window.setLayout(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);

Leave a Comment