Loading core/java/android/widget/Scroller.java +36 −8 Original line number Original line Diff line number Diff line Loading @@ -26,11 +26,39 @@ import android.view.animation.Interpolator; /** /** * This class encapsulates scrolling. The duration of the scroll * <p>This class encapsulates scrolling. You can use scrollers ({@link Scroller} * can be passed in the constructor and specifies the maximum time that * or {@link OverScroller}) to collect the data you need to produce a scrolling * the scrolling animation should take. Past this time, the scrolling is * animation—for example, in response to a fling gesture. Scrollers track * automatically moved to its final stage and computeScrollOffset() * scroll offsets for you over time, but they don't automatically apply those * will always return false to indicate that scrolling is over. * positions to your view. It's your responsibility to get and apply new * coordinates at a rate that will make the scrolling animation look smooth.</p> * * <p>Here is a simple example:</p> * * <pre> private Scroller mScroller = new Scroller(context); * ... * public void zoomIn() { * // Revert any animation currently in progress * mScroller.forceFinished(true); * // Start scrolling by providing a starting point and * // the distance to travel * mScroller.startScroll(0, 0, 100, 0); * // Invalidate to request a redraw * invalidate(); * }</pre> * * <p>To track the changing positions of the x/y coordinates, use * {@link #computeScrollOffset}. The method returns a boolean to indicate * whether the scroller is finished. If it isn't, it means that a fling or * programmatic pan operation is still in progress. You can use this method to * find the current offsets of the x and y coordinates, for example:</p> * * <pre>if (mScroller.computeScrollOffset()) { * // Get current x and y positions * int currX = mScroller.getCurrX(); * int currY = mScroller.getCurrY(); * ... * }</pre> */ */ public class Scroller { public class Scroller { private int mMode; private int mMode; Loading Loading @@ -272,8 +300,7 @@ public class Scroller { /** /** * Call this when you want to know the new location. If it returns true, * Call this when you want to know the new location. If it returns true, * the animation is not yet finished. loc will be altered to provide the * the animation is not yet finished. * new location. */ */ public boolean computeScrollOffset() { public boolean computeScrollOffset() { if (mFinished) { if (mFinished) { Loading Loading @@ -355,7 +382,8 @@ public class Scroller { } } /** /** * Start scrolling by providing a starting point and the distance to travel. * Start scrolling by providing a starting point, the distance to travel, * and the duration of the scroll. * * * @param startX Starting horizontal scroll offset in pixels. Positive * @param startX Starting horizontal scroll offset in pixels. Positive * numbers will scroll the content to the left. * numbers will scroll the content to the left. Loading Loading
core/java/android/widget/Scroller.java +36 −8 Original line number Original line Diff line number Diff line Loading @@ -26,11 +26,39 @@ import android.view.animation.Interpolator; /** /** * This class encapsulates scrolling. The duration of the scroll * <p>This class encapsulates scrolling. You can use scrollers ({@link Scroller} * can be passed in the constructor and specifies the maximum time that * or {@link OverScroller}) to collect the data you need to produce a scrolling * the scrolling animation should take. Past this time, the scrolling is * animation—for example, in response to a fling gesture. Scrollers track * automatically moved to its final stage and computeScrollOffset() * scroll offsets for you over time, but they don't automatically apply those * will always return false to indicate that scrolling is over. * positions to your view. It's your responsibility to get and apply new * coordinates at a rate that will make the scrolling animation look smooth.</p> * * <p>Here is a simple example:</p> * * <pre> private Scroller mScroller = new Scroller(context); * ... * public void zoomIn() { * // Revert any animation currently in progress * mScroller.forceFinished(true); * // Start scrolling by providing a starting point and * // the distance to travel * mScroller.startScroll(0, 0, 100, 0); * // Invalidate to request a redraw * invalidate(); * }</pre> * * <p>To track the changing positions of the x/y coordinates, use * {@link #computeScrollOffset}. The method returns a boolean to indicate * whether the scroller is finished. If it isn't, it means that a fling or * programmatic pan operation is still in progress. You can use this method to * find the current offsets of the x and y coordinates, for example:</p> * * <pre>if (mScroller.computeScrollOffset()) { * // Get current x and y positions * int currX = mScroller.getCurrX(); * int currY = mScroller.getCurrY(); * ... * }</pre> */ */ public class Scroller { public class Scroller { private int mMode; private int mMode; Loading Loading @@ -272,8 +300,7 @@ public class Scroller { /** /** * Call this when you want to know the new location. If it returns true, * Call this when you want to know the new location. If it returns true, * the animation is not yet finished. loc will be altered to provide the * the animation is not yet finished. * new location. */ */ public boolean computeScrollOffset() { public boolean computeScrollOffset() { if (mFinished) { if (mFinished) { Loading Loading @@ -355,7 +382,8 @@ public class Scroller { } } /** /** * Start scrolling by providing a starting point and the distance to travel. * Start scrolling by providing a starting point, the distance to travel, * and the duration of the scroll. * * * @param startX Starting horizontal scroll offset in pixels. Positive * @param startX Starting horizontal scroll offset in pixels. Positive * numbers will scroll the content to the left. * numbers will scroll the content to the left. Loading