|
@@ -41,7 +41,7 @@ public class PopupUtil {
|
|
|
/*底部显示PopupWindow*/
|
|
|
public static void showInBottom(Activity activity, int resourcesId, ShowListener showListener) {
|
|
|
View popupView = LayoutInflater.from(Utils.getApp()).inflate(resourcesId, null);
|
|
|
- PopupWindow popupWindow = createPopupWindow(popupView, activity, true);
|
|
|
+ PopupWindow popupWindow = createMatchWidthPopupWindow(popupView, activity, true);
|
|
|
popupWindow.showAtLocation(activity.getWindow().getDecorView(), Gravity.BOTTOM, 0, 0);
|
|
|
showListener.onShow(popupView, popupWindow);
|
|
|
}
|
|
@@ -157,6 +157,33 @@ public class PopupUtil {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /*创建PopupWindow*/
|
|
|
+ public static PopupWindow createMatchWidthPopupWindow(View popupView, Context activity, boolean touchable) {
|
|
|
+ CommonPopupWindow popupWindow = new CommonPopupWindow.Builder(activity)
|
|
|
+ //设置PopupWindow布局
|
|
|
+ .setView(popupView)
|
|
|
+ .setOutsideTouchable(touchable)
|
|
|
+ //设置宽高
|
|
|
+ .setWidthAndHeight(ViewGroup.LayoutParams.MATCH_PARENT,
|
|
|
+ ViewGroup.LayoutParams.WRAP_CONTENT)
|
|
|
+ //设置动画
|
|
|
+ //设置背景颜色,取值范围0.0f-1.0f 值越小越暗 1.0f为透明
|
|
|
+ .setBackGroundLevel(0.5f)
|
|
|
+ //设置PopupWindow里的子View及点击事件
|
|
|
+ .setViewOnclickListener(new CommonPopupWindow.ViewInterface() {
|
|
|
+ @Override
|
|
|
+ public void getChildView(View view, int layoutResId) {
|
|
|
+
|
|
|
+ }
|
|
|
+ })
|
|
|
+ //设置外部是否可点击 默认是true
|
|
|
+ .setOutsideTouchable(true)
|
|
|
+ //开始构建
|
|
|
+ .create();
|
|
|
+ return popupWindow;
|
|
|
+
|
|
|
+ } /*创建PopupWindow*/
|
|
|
+
|
|
|
public static PopupWindow createNoBackPopupWindow(View popupView, Context activity, int width, int height, boolean touchable) {
|
|
|
CommonPopupWindow popupWindow = new CommonPopupWindow.Builder(activity)
|
|
|
//设置PopupWindow布局
|