Google 致力于为黑人社区推动种族平等。查看具体举措

OnScrollListener

abstract class OnScrollListener
kotlin.Any
   ↳ androidx.recyclerview.widget.RecyclerView.OnScrollListener

An OnScrollListener can be added to a RecyclerView to receive messages when a scrolling event has occurred on that RecyclerView.

Summary

Public constructors

An OnScrollListener can be added to a RecyclerView to receive messages when a scrolling event has occurred on that RecyclerView.

Public methods
open Unit
onScrollStateChanged(@NonNull recyclerView: RecyclerView, newState: Int)

Callback method to be invoked when RecyclerView's scroll state changes.

open Unit
onScrolled(@NonNull recyclerView: RecyclerView, dx: Int, dy: Int)

Callback method to be invoked when the RecyclerView has been scrolled.

Public constructors

<init>

OnScrollListener()

An OnScrollListener can be added to a RecyclerView to receive messages when a scrolling event has occurred on that RecyclerView.

Public methods

onScrollStateChanged

open fun onScrollStateChanged(
    @NonNull recyclerView: RecyclerView,
    newState: Int
): Unit

Callback method to be invoked when RecyclerView's scroll state changes.

Parameters
recyclerView RecyclerView: The RecyclerView whose scroll state has changed.
newState Int: The updated scroll state. One of SCROLL_STATE_IDLE, SCROLL_STATE_DRAGGING or SCROLL_STATE_SETTLING.

onScrolled

open fun onScrolled(
    @NonNull recyclerView: RecyclerView,
    dx: Int,
    dy: Int
): Unit

Callback method to be invoked when the RecyclerView has been scrolled. This will be called after the scroll has completed.

This callback will also be called if visible item range changes after a layout calculation. In that case, dx and dy will be 0.

Parameters
recyclerView RecyclerView: The RecyclerView which scrolled.
dx Int: The amount of horizontal scroll.
dy Int: The amount of vertical scroll.