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

Problems with ScrollView #6

Open
pesjak opened this issue Jun 23, 2019 · 1 comment
Open

Problems with ScrollView #6

pesjak opened this issue Jun 23, 2019 · 1 comment

Comments

@pesjak
Copy link

pesjak commented Jun 23, 2019

Can't move the sliders if it is in Scroll layout.

@pesjak
Copy link
Author

pesjak commented Jun 23, 2019

I managed to fixed it. I dowloaded the library and changed onTouchEvent.
SOLUTION: parent.requestDisallowInterceptTouchEvent(true)

This is the full onTouchEvent code.

 @SuppressLint("ClickableViewAccessibility")
    override fun onTouchEvent(ev: MotionEvent): Boolean {
        //To make it touchable when inside of a scrollview
        parent.requestDisallowInterceptTouchEvent(true)

        val x = ev.x
        val y = ev.y

        when (ev.action) {
            MotionEvent.ACTION_DOWN -> {
                return true
            }
            MotionEvent.ACTION_MOVE -> {
                val touchAngleRad = atan2(center.y - y, x - center.x).toDouble()
                if (draggingSleep) {
                    val sleepAngleRad = Math.toRadians(sleepAngle)
                    val diff = Math.toDegrees(angleBetweenVectors(sleepAngleRad, touchAngleRad))
                    sleepAngle = to_0_720(sleepAngle + diff)
                    requestLayout()
                    notifyChanges()
                    return true
                } else if (draggingWake) {
                    val wakeAngleRad = Math.toRadians(wakeAngle)
                    val diff = Math.toDegrees(angleBetweenVectors(wakeAngleRad, touchAngleRad))
                    wakeAngle = to_0_720(wakeAngle + diff)
                    requestLayout()
                    notifyChanges()
                    return true
                }
            }
            MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> {
                draggingSleep = false
                draggingWake = false
            }
        }
        return super.onTouchEvent(ev)
    }

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