0

I what the Dialog to cover up the whole screen width.

Hence:

Dialog dialog = new Dialog(this);
LayoutParams params = dialog.getWindow().getAttributes();
params.height = LayoutParams.MATCH_PARENT;
params.width = LayoutParams.MATCH_PARENT;
dialog.getWindow().setAttributes(params);

But the result is:

enter image description here

Skip is a button in a parent layout (MATCH_PARENT as width and height and 10dp padding and orange background).

Even in this answer the final result has some gaps on sides.

Is there a way to cover the whole screen width without any gaps?

Community
  • 1
  • 1
Archie.bpgc
  • 23,812
  • 38
  • 150
  • 226

1 Answers1

0

The solution that worked for me was the following:

Grab the device dimensions using:

WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
Point size = new Point();
display.getSize(size);

Then set the width of the dialog to the screen width

params.width = size.x;
Nyx
  • 2,233
  • 1
  • 12
  • 25