Android7.0中文文档(API)-- Scroller

 完整内容,请查看:http://www.zhdoc.net/android/reference/android/widget/Scroller.html

Scroller

public class Scroller
extends Object

java.lang.Object
   ↳android.widget.Scroller


This class encapsulates scrolling. You can use scrollers (Scroller or OverScroller) to collect the data you need to produce a scrolling animation—for example, in response to a fling gesture. Scrollers track scroll offsets for you over time, but they don't automatically apply those 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.
这个类封装了滚动行为。您可以使用滚动条(ScrollerOverScroller)来收集所需的数据,以生成滚动的动画,例如,对fling的手势进行响应。随着时间的推移,滚动条会为你跟踪滚动的偏移量,但它们不会自动将这些位置设置到你的视图中。你的责任是获取和设置新的坐标,以使滚动的动画看起来平滑。

Here is a simple example:
这里有个简单的例子:

 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(); }

To track the changing positions of the x/y coordinates, use 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:
为了跟踪X/Y坐标的位置改变,请使用computeScrollOffset()方法。该方法返回一个布尔值,以指示是否完成了滚动。如果不是这样,那就意味着一个fling或编程的操作仍然在进行中。你可以调用此方法来查找当前的X和Y坐标的偏移,例如:

if (mScroller.computeScrollOffset()) { // Get current x and y positions int currX = mScroller.getCurrX(); int currY = mScroller.getCurrY(); ...}

摘要


Public构造方法

Scroller(Context context)

Create a Scroller with the default duration and interpolator.
使用默认的持续时间和插值器来创建一个Scroller对象。

Scroller(Context context, Interpolator interpolator)

Create a Scroller with the specified interpolator.
使用指定的插值器来创建一个Scroller对象。

Scroller(Context context, Interpolator interpolator, boolean flywheel)

Create a Scroller with the specified interpolator.
使用指定的插值器来创建一个Scroller对象。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值