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 ?
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.