Android 當(dāng)彈出一個(gè)對話框時(shí),如何實(shí)現(xiàn)背景模糊效果?

(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

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容