leotyndale/EnFloatingView

作者能否提供一个限制移动区域的方法

ZevShiShi opened this issue · 1 comments

updateViewPosition函数我看可以控制移动范围

目前只能先反射获取mStatusBarHeight,mScreenHeight来控制移动区域,后面有遇到这个问题的同学可以先这样解决,希望作者出个函数来解决

    init {
        this.post {
            // 设置初始位置
            x = (ScreenUtils.getScreenWidth() - width - ConvertUtils.dp2px(5f)).toFloat()
            y =
                (ScreenUtils.getScreenHeight() - height - BarUtils.getStatusBarHeight() - BarUtils.getActionBarHeight() - ConvertUtils.dp2px(
                    50f
                )).toFloat()
            val cls = FloatingMagnetView::class.java
            val f2 = cls.getDeclaredField("mStatusBarHeight")
            f2.isAccessible = true
            val mStatusBarHeight = f2.getInt(this)
            f2.setInt(this, mStatusBarHeight + ConvertUtils.dp2px(50f))
        }
    }

    override fun updateSize() {
        super.updateSize()
        val cls = FloatingMagnetView::class.java
        val f = cls.getDeclaredField("mScreenHeight")
        f.isAccessible = true
        val mScreenHeight = f.getInt(this)
        f.setInt(this, mScreenHeight - ConvertUtils.dp2px(54f))
    }