您好,登錄后才能下訂單哦!
Android PopWindow 設置背景亮度的實例
設置背景
/** * 設置添加屏幕的背景透明度 * @param bgAlpha */ public void backgroundAlpha(float bgAlpha) { WindowManager.LayoutParams lp = getWindow().getAttributes(); lp.alpha = bgAlpha; //0.0-1.0 getWindow().setAttributes(lp); }
調用代碼
recomPopup = new RecomPopup(mContext); recomPopup.setShowListener(new RecomPopup.ShowListener() { @Override public void show() { backgroundAlpha(0.6f); } }); recomPopup.setDismissListener(new RecomPopup.DismissListener() { @Override public void dismiss() { backgroundAlpha(1f); } }); recomPopup.showAtLocation(include_bottom, Gravity.NO_GRAVITY, 0, DevicesInfoUtils.getScreenHeight(mContext) - recomPopup.getHeight());
PopWindow代碼
private ShowListener showListener; private DismissListener dismissListener; @Override public void showAtLocation(View parent, int gravity, int x, int y) { super.showAtLocation(parent, gravity, x, y); if (showListener != null){ showListener.show(); } } @Override public void dismiss() { super.dismiss(); if (dismissListener != null){ dismissListener.dismiss(); } } public void setShowListener(ShowListener showListener) { this.showListener = showListener; } public void setDismissListener(DismissListener dismissListener) { this.dismissListener = dismissListener; } public interface ShowListener{ void show(); } public interface DismissListener{ void dismiss(); }
以上就是Android PopWindow 設置背景亮度的實例,如有疑問請留言或者到本站社區交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。