public static abstract class RecyclerView.SmoothScroller
extends Object
java.lang.Object | |
↳ | android.support.v7.widget.RecyclerView.SmoothScroller |
Known Direct Subclasses |
用于平滑滚动的基类。 处理目标视图位置的基本跟踪并提供触发编程滚动的方法。
也可以看看:
Nested classes |
|
---|---|
class |
RecyclerView.SmoothScroller.Action 通过 |
Public constructors |
|
---|---|
RecyclerView.SmoothScroller() |
Public methods |
|
---|---|
View |
findViewByPosition(int position) |
int |
getChildCount() |
int |
getChildPosition(View view) |
RecyclerView.LayoutManager |
getLayoutManager() |
int |
getTargetPosition() 返回目标项目的适配器位置 |
void |
instantScrollToPosition(int position) 此方法已弃用。 使用 |
boolean |
isPendingInitialRun() 如果SmoothScroller已启动,但尚未收到第一个动画回调,则返回true。 |
boolean |
isRunning() |
void |
setTargetPosition(int targetPosition) |
Protected methods |
|
---|---|
void |
normalize(PointF scrollVector) 规格化矢量。 |
void |
onChildAttachedToWindow(View child) |
abstract void |
onSeekTargetStep(int dx, int dy, RecyclerView.State state, RecyclerView.SmoothScroller.Action action) RecyclerView会在每次滚动时调用此方法,直到它可以在布局中找到目标位置。 |
abstract void |
onStart() 当平滑滚动开始时调用。 |
abstract void |
onStop() 当平滑滚轮停止时调用。 |
abstract void |
onTargetFound(View targetView, RecyclerView.State state, RecyclerView.SmoothScroller.Action action) 目标位置布局时调用。 |
final void |
stop() 停止在每个动画回调中运行SmoothScroller。 |
Inherited methods |
|
---|---|
From class java.lang.Object
|
RecyclerView.SmoothScroller ()
View findViewByPosition (int position)
Parameters | |
---|---|
position |
int
|
Returns | |
---|---|
View |
也可以看看:
RecyclerView.LayoutManager getLayoutManager ()
Returns | |
---|---|
RecyclerView.LayoutManager |
The LayoutManager to which this SmoothScroller is attached. Will return null after the SmoothScroller is stopped. |
int getTargetPosition ()
返回目标项目的适配器位置
Returns | |
---|---|
int |
Adapter position of the target item or NO_POSITION if no target view is set. |
void instantScrollToPosition (int position)
此方法已弃用。
使用jumpTo(int)
。
Parameters | |
---|---|
position |
int
|
也可以看看:
boolean isPendingInitialRun ()
如果SmoothScroller已启动,但尚未收到第一个动画回调,则返回true。
Returns | |
---|---|
boolean |
True if this SmoothScroller is waiting to start |
boolean isRunning ()
Returns | |
---|---|
boolean |
True if SmoothScroller is currently active |
void setTargetPosition (int targetPosition)
Parameters | |
---|---|
targetPosition |
int
|
void normalize (PointF scrollVector)
规格化矢量。
Parameters | |
---|---|
scrollVector |
PointF : The vector that points to the target scroll position |
void onSeekTargetStep (int dx, int dy, RecyclerView.State state, RecyclerView.SmoothScroller.Action action)
RecyclerView会在每次滚动时调用此方法,直到它可以在布局中找到目标位置。
SmoothScroller应检查dx,dy,如果应该更改滚动,请更新提供的 RecyclerView.SmoothScroller.Action
以定义下一个滚动。
Parameters | |
---|---|
dx |
int : Last scroll amount horizontally |
dy |
int : Last scroll amount verticaully |
state |
RecyclerView.State : Transient state of RecyclerView |
action |
RecyclerView.SmoothScroller.Action : If you want to trigger a new smooth scroll and cancel the previous one, update this object. |
void onStart ()
当平滑滚动开始时调用。 这可能是设置的好时机。
void onTargetFound (View targetView, RecyclerView.State state, RecyclerView.SmoothScroller.Action action)
目标位置布局时调用。 这是SmoothScroller将收到的最后一个回调,它应该更新提供的RecyclerView.SmoothScroller.Action
以定义滚动细节到目标视图。
Parameters | |
---|---|
targetView |
View : The view element which render the target position. |
state |
RecyclerView.State : Transient state of RecyclerView |
action |
RecyclerView.SmoothScroller.Action : Action instance that you should update to define final scroll action towards the targetView |
void stop ()
停止在每个动画回调中运行SmoothScroller。 请注意,这不会取消任何现有RecyclerView.SmoothScroller.Action
通过更新onTargetFound(android.view.View, RecyclerView.State, SmoothScroller.Action)
或者onSeekTargetStep(int, int, RecyclerView.State, SmoothScroller.Action)
。