简体   繁体   中英

AlertDialog White Part At The Bottom

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM