2

I have a seekbar and I would like to set the position (progress) to the match the position of your finger when you first touch it... I want you to be able to touch it and have it snap to where you touched it immediately, and then function normally allowing you to drag it until you remove your finger.

I know I will have to do this in the onStartTrackingTouch() function and I will have to call seekBar.setProgress() but I'm not sure how to get the seekBar progress equivalent of the location of your touch.

Thank you.

4

1 回答 1

2

这是一个有效的解决方案:

private void onStartTrackingTouch(MotionEvent event) {
    firstTouchAngle = TouchAngle;
}


private void onUpdateTouch(MotionEvent event) {
    newTouchAngle = TouchAngle;
    if (Math.abs(newTouchAngle - firstTouchAngle) > 3) {
        //do something
    }
}
于 2018-12-19T17:49:10.530 回答