Android背景虚化的PopupWindow 可指定虚化区域

版权声明:转载请注明出处 https://blog.csdn.net/u011788083/article/details/51558998

转载请注明出处

使用方式同系统PopupWindow:

//初始化并设置返回键以及点击外部消失
mPopupWindow = new BackgroundBlurPopupWindow(mTextView, WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT, this, true);
mPopupWindow.setFocusable(true);
mPopupWindow.setBackgroundDrawable(new ColorDrawable());

可配置背景变暗动画、位置、颜色,不配置默认全屏展示暗黑色:

mPopupWindow.setBlurRadius(BackgroundBlurPopupWindow.DEFAULT_BLUR_RADIUS);//配置虚化比例
mPopupWindow.setDarkStyle(R.style.MyDarkStyle);//动画
mPopupWindow.setDarkColor(Color.parseColor("#a0880000"));//颜色
//mPopupWindow.darkFillScreen();//全屏
mPopupWindow.drakLeftOf(mBtnRight);//左于
mPopupWindow.darkRightOf(mBtnLeft);//右于
mPopupWindow.darkAbove(mBtnBottom);//上于
mPopupWindow.darkBelow(mBtnTop);//下于
mPopupWindow.darkFillView(mBtnView);//覆盖视图
mPopupWindow.showAtLocation(mBtnCenter, Gravity.CENTER, 0, 0);//弹出PopupWindow

效果如下:

下载地址:
https://github.com/BakerJQ/BackgroundBlurPopupWindow

猜你喜欢

转载自blog.csdn.net/u011788083/article/details/51558998
今日推荐