Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ZevShiShi opened this issue Sep 10, 2021 · 1 comment
Open

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

ZevShiShi opened this issue Sep 10, 2021 · 1 comment

Comments

@ZevShiShi
Copy link

ZevShiShi commented Sep 10, 2021

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

@ZevShiShi
Copy link
Author

ZevShiShi commented Sep 10, 2021

目前只能先反射获取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))
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant