window.setDimAmount(0f);//去掉遮罩层(全透明)
android.view.ViewGroup.LayoutParams
android.view.WindowManager.LayoutParams 二者存在微量差别,在dialog设置宽、高时应使用android.view.WindowManager.LayoutParams设置
import android.view.WindowManager.LayoutParams;
...
..
//设置dialog自适应宽度、高度 (android.view.WindowManager.LayoutParams)
Window window = this.getWindow();
window.setBackgroundDrawableResource(R.color.transparent);
LayoutParams layoutParams = window.getAttributes();
layoutParams.alpha = 0.9f;
layoutParams.width = LayoutParams.WRAP_CONTENT;
layoutParams.height = LayoutParams.WRAP_CONTENT;
layoutParams.gravity = Gravity.CENTER;
window.setAttributes(layoutParams);