摘要: 在代码中设置dialog全屏且透明的方法: publicclassMyDialogextendsDialog{ publicMyDialog(Contextcontext){ super(context,android.R.style.Theme);//在这需要设置个系统的theme替换dialog默认的主题,不设置下面的window设置都无效 setOwnerActivity((Activit
在代码中设置dialog全屏且透明的方法:
public class MyDialogextends Dialog{
public MyDialog (Context context) {
super(context,android.R.style. Theme); //在这需要设置个系统的theme替换dialog默认的主题,不设置下面的window设置都无效
setOwnerActivity((Activity)(context));
Window window = getWindow();
requestWindowFeature(Window. FEATURE_NO_TITLE); //去掉dialog的title
window.addFlags(WindowManager.LayoutParams. FLAG_FULLSCREEN); //全屏的flag
window.setBackgroundDrawableResource(android.R.color.transparent); //设置window背景透明
WindowManager.LayoutParams lp = window.getAttributes();
lp.alpha = 1.0f;
lp.dimAmount = 0.0f; //dimAmount在0.0f和1.0f之间,0.0f完全不暗,1.0f全暗
window.setAttributes(lp);
this.setCancelable( false);
}
public void show(FlashAd flashAd){
this.setContentView(flashAd);
this.show();
}
}