Most visited

Recently visited

RecyclerView.SmoothScroller

public static abstract class RecyclerView.SmoothScroller
extends Object

java.lang.Object
   ↳ android.support.v7.widget.RecyclerView.SmoothScroller
Known Direct Subclasses


用于平滑滚动的基类。 处理目标视图位置的基本跟踪并提供触发编程滚动的方法。

也可以看看:

Summary

Nested classes

class RecyclerView.SmoothScroller.Action

通过RecyclerView.SmoothScroller保存有关平滑滚动请求的RecyclerView.SmoothScroller

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)

此方法已弃用。 使用jumpTo(int)

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

Public constructors

RecyclerView.SmoothScroller

RecyclerView.SmoothScroller ()

Public methods

findViewByPosition

View findViewByPosition (int position)

Parameters
position int
Returns
View

也可以看看:

getChildCount

int getChildCount ()

Returns
int

也可以看看:

getChildPosition

int getChildPosition (View view)

Parameters
view View
Returns
int

也可以看看:

getLayoutManager

RecyclerView.LayoutManager getLayoutManager ()

Returns
RecyclerView.LayoutManager The LayoutManager to which this SmoothScroller is attached. Will return null after the SmoothScroller is stopped.

getTargetPosition

int getTargetPosition ()

返回目标项目的适配器位置

Returns
int Adapter position of the target item or NO_POSITION if no target view is set.

instantScrollToPosition

void instantScrollToPosition (int position)

此方法已弃用。
使用jumpTo(int)

Parameters
position int

也可以看看:

isPendingInitialRun

boolean isPendingInitialRun ()

如果SmoothScroller已启动,但尚未收到第一个动画回调,则返回true。

Returns
boolean True if this SmoothScroller is waiting to start

isRunning

boolean isRunning ()

Returns
boolean True if SmoothScroller is currently active

setTargetPosition

void setTargetPosition (int targetPosition)

Parameters
targetPosition int

Protected methods

normalize

void normalize (PointF scrollVector)

规格化矢量。

Parameters
scrollVector PointF: The vector that points to the target scroll position

onChildAttachedToWindow

void onChildAttachedToWindow (View child)

Parameters
child View

onSeekTargetStep

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.

onStart

void onStart ()

当平滑滚动开始时调用。 这可能是设置的好时机。

onStop

void onStop ()

当平滑滚轮停止时调用。 这是清理你的国家等的好地方。

也可以看看:

onTargetFound

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

stop

void stop ()

停止在每个动画回调中运行SmoothScroller。 请注意,这不会取消任何现有RecyclerView.SmoothScroller.Action通过更新onTargetFound(android.view.View, RecyclerView.State, SmoothScroller.Action)或者onSeekTargetStep(int, int, RecyclerView.State, SmoothScroller.Action)

Hooray!