Android PopupWindow(悬浮框)

under Android  tag     Published on October 29th , 2020 at 09:07 am

view为需要悬浮的layout, v为被点击的控件

PopupWindow popupWindow = new PopupWindow(view, 500, ViewGroup.LayoutParams.WRAP_CONTENT, true);
            popupWindow.setTouchable(true);//点击弹窗外围会消失
            popupWindow.setBackgroundDrawable(new ColorDrawable());//设置弹窗颜色,一定要设置,不然弹窗不显示
            popupWindow.showAsDropDown(v, -530, 0);//偏移的位置

本文由 surface 创作,采用 知识共享署名4.0 国际许可协议进行许可,转载前请务必署名
  文章最后更新时间为:November 7th , 2020 at 10:28 am
分享到:Twitter  Weibo  Facebook