本文介紹了使用 Dialog 自定義屏幕變暗的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!
問(wèn)題描述
在 Android 中,當(dāng)您彈出一個(gè)對(duì)話框時(shí),它后面的屏幕會(huì)變暗.有什么辦法可以控制它的外觀嗎?例如使其變暗或使用某種模式?
In Android when you pop up a dialog the screen behind it dims. Is there any way to control what that looks like? For example making it dim more or less or using some kind of a pattern?
推薦答案
是的.你可以控制它.
創(chuàng)建對(duì)話框后:
WindowManager.LayoutParams lp = dialog.getWindow().getAttributes();
lp.dimAmount = 0.0f; // Dim level. 0.0 - no dim, 1.0 - completely opaque
dialog.getWindow().setAttributes(lp);
更新:您甚至可以在對(duì)話框后面添加模糊:
Upd: you can even add blur behind the dialog:
dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
Upd2:不推薦使用模糊從 API14 開(kāi)始:
此常量在 API 級(jí)別 14 中已棄用.
不再支持模糊.
This constant was deprecated in API level 14.
Blurring is no longer supported.
這篇關(guān)于使用 Dialog 自定義屏幕變暗的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!