1. 程式人生 > >Android彈出Dialog使背景變暗的實現方式

Android彈出Dialog使背景變暗的實現方式

背景變暗

WindowManager.LayoutParams lp = getWindow().getAttributes();
lp.alpha = 0.6f;
getWindow().setAttributes(lp);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);

背景恢復

WindowManager.LayoutParams lp = getWindow().getAttributes();
lp.alpha = 1.0f;
getWindow().setAttributes(lp);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);

若不顯示設定FLAG_DIM_BEHIND引數在大多數手機上也能work,但是在某些手機如華為Mate7上不能正常work,顯示設定之後能夠適配更多機型。

相關推薦

no