1

I am using AlertDialog but android adds white space at the bottom of AlertDialog.

I found that the problem is happening when i use the

alertDialog.getWindow().setLayout(600, 400);

The creation of AlertDialog is done like :

AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setView(layout);
alertDialog = builder.create();
alertDialog.show();
alertDialog.getWindow().setLayout(600, 400); //Controlling width and height.

I show the AlertDialog in a Fragment class and Fragment class belongs to AppCompatActivity.

How to remove this white space ?

enter image description here

nihasmata
  • 652
  • 1
  • 8
  • 28

1 Answers1

0

You should use alertDialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);

to wrapping things use wrap_content in your xml file.

Check one more thing, have you used any layout element with static height or not. Should use wrap_content in all parent xml elements.

You can also use android:background="#80000000" // transparent code in parent most layout element.

Exigente05
  • 2,161
  • 3
  • 22
  • 42