(1)設(shè)置透明度(這是窗體本身的透明度,非背景)
WindowManager.LayoutParams lp=getWindow().getAttributes();
lp.alpha=0.3f;
getWindow().setAttributes(lp);
alpha在0.0f到1.0f之間。1.0完全不透明,0.0f完全透明
(2)設(shè)置黑暗度( 調(diào)光 )
WindowManager.LayoutParams lp=getWindow().getAttributes();
lp.dimAmount=0.5f;
getWindow().setAttributes(lp);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
dimAmount在0.0f和1.0f之間,0.0f完全不暗,1.0f全暗
參考:http://stackoverflow.com/questions/10372404/alternative-to-flag-blur-behind-in-android
3 設(shè)置背景模糊
getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND,
WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
其它資料:參考:http://http://862123204-qq-com.iteye.com/blog/2195310
http://stackoverflow.com/questions/10372404/alternative-to-flag-blur-behind-in-android
(4)一個(gè)背景模糊控件
https://github.com/faradaj/BlurBehind