Android Open Source - Coloring-book Fixed Speed Scroller

From Project

Back to project page Coloring-book.


The source code is released under:

Apache License

If you think the Android project Coloring-book listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/*  w ww. j  ava2 s.c  o  m*/

import android.content.Context;
import android.view.animation.Interpolator;
import android.widget.Scroller;

public class FixedSpeedScroller extends Scroller {

    private int mDuration = 1;
    private double mScrollFactor = 10;

    public FixedSpeedScroller(Context context, Interpolator interpolator) {
        super(context, interpolator);

    public void startScroll(int startX, int startY, int dx, int dy) {
        // Ignore received duration, use fixed one instead
        super.startScroll(startX, startY, dx, dy, mDuration);

    public void setScrollDurationFactor(double scrollFactor) {
        mScrollFactor = scrollFactor;

    public void startScroll(int startX, int startY, int dx, int dy,
                            int duration) {

        int newDur = duration;
        int scrollFactor = 2;

        if (duration == 200) {
            newDur = 200;
            scrollFactor = 5;
        super.startScroll(startX, startY, dx, dy,
                (int) (newDur * scrollFactor));

Java Source Code List