PopupWindow 设置背景颜色

 public void setBackgroundAlpha(Activity activity, float bgAlpha) {
        WindowManager.LayoutParams lp = activity.getWindow().getAttributes();
        lp.alpha = bgAlpha;
        if (bgAlpha == 1) {
            activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
        } else {
            activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
        }
        activity.getWindow().setAttributes(lp);
    }



setBackgroundAlpha(RefrigeratorActivity.this, 1.0f);
setBackgroundAlpha(RefrigeratorActivity.this, 0.5f);

 

你可能感兴趣的:(Android基础)