Android – speed limit for scrolling views

My app scrolls so fast! How do I limit the scrolling speed of the scrolling view in my Android application? Rolling can be very fast, rolling speed is meaningless

resolvent:

This thread is old, but I will answer a partial solution: limit the throwing speed. Feel free to comment so that I can improve my solution

As described in the developer Training Guide:

This is where I need the speed limit. Therefore, in the custom Scrollview (whether horizontal or vertical), override the flying method like this

@Override
public void fling(int veLocityY) {
    int topVeLocityY = (int) ((Math.min(Math.abs(veLocityY), MAX_SCROLL_SPEED) ) * Math.signum(veLocityY));
    super.fling(topVeLocityY);
}

I found that velocityy (in the horizontal scrolling view, it will be velocityx) may be between - 16000 and 16000. Negative just means scrolling backward. I'm still testing this value. I've only tested it on one device. I'm not sure whether the old device / API version is the same. I'll edit this later

(int) ((Math.min(Math.abs(veLocityY), MAX_SCROLL_SPEED) ) * Math.signum(veLocityY));

What I do there is get my constant max_ SCROLL_ The minimum value between speed and the original velocityy, and then get the symbol of the original velocityy. We need the flag to scroll back

Finally, send back the modified velocityy

This is a partial solution because if the user keeps pressing the scroll view, the speed will not change

Again, improve my answers at any time. I'm still learning

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>