# Android-BackgroundDarkPopupWindow **Repository Path**: bakerj/Android-BackgroundDarkPopupWindow ## Basic Information - **Project Name**: Android-BackgroundDarkPopupWindow - **Description**: 背景变暗的PopupWindow,可指定变暗区域 - **Primary Language**: Android - **License**: Not specified - **Default Branch**: master - **Homepage**: https://github.com/BakerJQ/Android-BackgroundDarkPopupWindow - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2017-07-28 - **Last Updated**: 2024-11-22 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Android-BackgroundDarkPopupWindow [![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg)](https://www.apache.org/licenses/LICENSE-2.0.html) 背景可变暗的PopupWindow ## Screenshot ![](https://github.com/BakerJQ/Android-BackgroundDarkPopupWindow/raw/master/Screenshots/show.gif) ## Gradle导入 ``` groovy compile 'com.bakerj:backgrounddark-popupwindow:1.0.0' ``` ## 如何使用 ### 初始化 和系统PopupWindow使用方式一样 ```java mPopupWindow = new BackgroundDarkPopupWindow(mTextView, WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT); mPopupWindow.setFocusable(true); mPopupWindow.setBackgroundDrawable(new BitmapDrawable()); mPopupWindow.setAnimationStyle(android.R.style.Animation_Dialog); ``` #### 设置变暗区域 ```java case R.id.top: mTextView.setText("This is a popupwindow\n\ndark on bottom"); mPopupWindow.setDarkStyle(-1); mPopupWindow.setDarkColor(Color.parseColor("#a0000000")); mPopupWindow.resetDarkPosition(); mPopupWindow.darkBelow(mBtnTop); mPopupWindow.showAsDropDown(mBtnTop, mBtnTop.getRight() / 2, 0); break; case R.id.left: mTextView.setText("This is a popupwindow\n\ndark on right"); mPopupWindow.setDarkStyle(-1); mPopupWindow.setDarkColor(Color.parseColor("#a0000000")); mPopupWindow.resetDarkPosition(); mPopupWindow.darkRightOf(mBtnLeft); mPopupWindow.showAtLocation(mBtnLeft, Gravity.CENTER_VERTICAL | Gravity.LEFT, 0, 0); break; case R.id.right: mTextView.setText("This is a popupwindow\n\ndark on left"); mPopupWindow.setDarkStyle(-1); mPopupWindow.setDarkColor(Color.parseColor("#a0000088")); mPopupWindow.resetDarkPosition(); mPopupWindow.drakLeftOf(mBtnRight); mPopupWindow.showAtLocation(mBtnRight, Gravity.CENTER_VERTICAL | Gravity.RIGHT, 0, 0); break; case R.id.bottom: mTextView.setText("This is a popupwindow\n\ndark on top"); mPopupWindow.setDarkStyle(-1); mPopupWindow.setDarkColor(Color.parseColor("#a0008800")); mPopupWindow.resetDarkPosition(); mPopupWindow.darkAbove(mBtnBottom); mPopupWindow.showAtLocation(mBtnBottom, Gravity.CENTER_HORIZONTAL, 0, mBtnBottom.getTop()); break; case R.id.center: mTextView.setText("This is a popupwindow\n\ndark in center"); mPopupWindow.setDarkStyle(R.style.MyDarkStyle); mPopupWindow.setDarkColor(Color.parseColor("#a0880000")); mPopupWindow.resetDarkPosition(); mPopupWindow.drakLeftOf(mBtnRight); mPopupWindow.darkRightOf(mBtnLeft); mPopupWindow.darkAbove(mBtnBottom); mPopupWindow.darkBelow(mBtnTop); mPopupWindow.showAtLocation(mBtnCenter, Gravity.CENTER, 0, 0); break; case R.id.all: mTextView.setText("This is a popupwindow\n\ndark fill all"); mPopupWindow.setDarkStyle(-1); mPopupWindow.setDarkColor(Color.parseColor("#a0000000")); mPopupWindow.resetDarkPosition(); mPopupWindow.darkFillScreen(); mPopupWindow.showAtLocation(mBtnAll, Gravity.CENTER, 0, 0); break; case R.id.view: mTextView.setText("This is a popupwindow\n\ndark fill view"); mPopupWindow.setDarkStyle(-1); mPopupWindow.setDarkColor(Color.parseColor("#a0000000")); mPopupWindow.resetDarkPosition(); mPopupWindow.drakFillView(mBtnView); mPopupWindow.showAtLocation(mBtnView, Gravity.CENTER, 0, 0); break; ```