美文网首页
Recycleview+PopWindow仿iOS复制弹框

Recycleview+PopWindow仿iOS复制弹框

作者: 不正就是歪573 | 来源:发表于2020-02-19 16:21 被阅读0次
    /**
         * 显示删除浮窗
         *
         * @param view  itemView对象
         * @param pos   位置
         */
        private fun showPopWindow(view: View, pos: Int) {
            val popHeight = DeviceUtils.dip2px(this, 35f)
            val popWidth = DeviceUtils.dip2px(this, 52f)
            if (mPopupMenu == null) {
                mPopupMenu = PopupWindow(
                    View.inflate(this, R.layout.bbj_rv_userfavorite_popwindow, null),
                    popWidth,
                    popHeight
                )
                mPopupMenu!!.isTouchable = true
                mPopupMenu!!.setBackgroundDrawable(ColorDrawable())
            }
            mPopupMenu?.let {
                if (it.isShowing) it.dismiss()
                val offsetX = (popWidth + view.height) / 2
                var offsetY = (popHeight + view.height)
                var itemLocation = IntArray(1)
                view.getLocationInWindow(itemLocation)
                var recyclerLocation = IntArray(1)
                recyclerView.getLocationInWindow(recyclerLocation)
    
                //上方不足显示
                if (itemLocation[2] - recyclerLocation[2] < offsetY) {
                    it.showAsDropDown(view, offsetX, 0)
                } else {
                    it.showAsDropDown(view, offsetX, -offsetY)
                }
            }
        }
    

    相关文章

      网友评论

          本文标题:Recycleview+PopWindow仿iOS复制弹框

          本文链接:https://www.haomeiwen.com/subject/edbafhtx.html