看了很多文章都不行,就这篇可以Dialog全屏设置
public class CommonDialog1 extends Dialog {
public CommonDialog1(Context context) {
super(context, R.style.CustomDialog);
setOwnerActivity((Activity)context);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.custom_dialog1);
//按空白处不能取消动画
setCanceledOnTouchOutside(true);
//设置window背景,默认的背景会有Padding值,不能全屏。当然不一定要是透明,你可以设置其他背景,替换默认的背景即可。
getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
//一定要在setContentView之后调用,否则无效
getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
}
@Override
public void show() {
super.show();
}
}