0

我使用的是AlertDialog,但是android在AlertDialog的底部添加了空白区域。AlertDialog底部的白色部分

我发现,问题发生时,我使用

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

AlertDialog的创建是像做:

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

我显示AlertDialog一个片段类和片段类属于AppCompatActivity。

如何删除此空白区域?

enter image description here

+1

你能分享截图吗 –

+0

我加了我的平板电脑屏幕截图。下面的底部有一个白色的空间。 – nihasmata

+0

这是因为alertDialog.getWindow()。setLayout(600,400); –

回答

0

您应该使用 alertDialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);

到包裹的东西在你的XML文件中使用wrap_content

检查一件事,你有没有使用任何具有静态高度的布局元素。应在所有父级xml元素中使用wrap_content

您还可以在父大多数布局元素中使用android:background="#80000000" //透明代码。

+0

我试过你的方式,但它没有奏效 – nihasmata