private void showDetailsMoreWindow(View asDropDown) { if (popupWindow == null) { View view = LayoutInflater.from(this).inflate( R.layout.poupwind_details_more, null); tvDetailesMoreHome = (TextView) view.findViewById(R.id.tv_detailes_more_home); tvDetailesMoreCollect = (TextView) view.findViewById(R.id.tv_detailes_more_collect); tvDetailesMoreShare = (TextView) view.findViewById(R.id.tv_detailes_more_share); tvDetailesMoreHome.setOnClickListener(this); tvDetailesMoreCollect.setOnClickListener(this); tvDetailesMoreShare.setOnClickListener(this); popupWindow = new PopupWindow(view, WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT, false); popupWindow = new PopupWindow(view); } // 使其聚集 popupWindow.setFocusable(true); // 设置允许在外点击消失 popupWindow.setOutsideTouchable(true); // 这个是为了点击“返回Back”也能使其消失,并且并不会影响背景 popupWindow.setBackgroundDrawable(new BitmapDrawable()); // 设置SelectPicPopupWindow弹出窗体的宽 int width = this.getWindowManager().getDefaultDisplay().getWidth(); popupWindow.setWidth(WindowManager.LayoutParams.WRAP_CONTENT); // 设置SelectPicPopupWindow弹出窗体的高 popupWindow.setHeight(WindowManager.LayoutParams.WRAP_CONTENT); // 设置SelectPicPopupWindow弹出窗体动画效果 // popupWindow.setAnimationStyle(R.style.PopupAnimation); popupWindow.showAsDropDown(asDropDown); }
Popupwind简单实现
最新推荐文章于 2022-05-05 15:31:52 发布