设置透明度(这是窗体本身的透明度,非背景)
WindowManager.LayoutParams windowLP = getWindow().getAttributes();
windowLP.alpha = 0.5f;
getWindow().setAttributes(windowLP);
设置灰度(背景灰度)
WindowManager.LayoutParams windowLPs = getWindow().getAttributes();
windowLP.dimAmount = 1.0f;
getWindow().setAttributes(windowLP);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);