Stay organized with collections
Save and categorize content based on your preferences.
interface OnScrollChangeListener
Interface definition for a callback to be invoked when the scroll X or Y positions of a view change.
Note: Some views handle scrolling independently from View and may have their own separate listeners for scroll-type events. For example, ListView
allows clients to register an AbsListView.OnScrollListener
to listen for changes in list scroll position.
Summary
Public methods |
abstract Unit |
Called when the scroll position of a view changes.
|
Public methods
abstract fun onScrollChange(
v: View!,
scrollX: Int,
scrollY: Int,
oldScrollX: Int,
oldScrollY: Int
): Unit
Called when the scroll position of a view changes.
Parameters |
v |
View!: The view whose scroll position has changed. |
scrollX |
Int: Current horizontal scroll origin. |
scrollY |
Int: Current vertical scroll origin. |
oldScrollX |
Int: Previous horizontal scroll origin. |
oldScrollY |
Int: Previous vertical scroll origin. |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[null,null,["Last updated 2025-02-10 UTC."],[],[],null,["# View.OnScrollChangeListener\n\nAdded in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nOnScrollChangeListener\n======================\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/view/View.OnScrollChangeListener \"View this page in Java\") \n\n```\ninterface OnScrollChangeListener\n```\n\n|-----------------------------------------------|\n| [android.view.View.OnScrollChangeListener](#) |\n\nInterface definition for a callback to be invoked when the scroll X or Y positions of a view change.\n\n**Note:** Some views handle scrolling independently from View and may have their own separate listeners for scroll-type events. For example, [ListView](../widget/ListView.html#) allows clients to register an [AbsListView.OnScrollListener](../widget/AbsListView.html#setOnScrollListener(android.widget.AbsListView.OnScrollListener)) to listen for changes in list scroll position.\n\nSummary\n-------\n\n| Public methods ||\n|---------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onScrollChange](#onScrollChange(android.view.View,%20kotlin.Int,%20kotlin.Int,%20kotlin.Int,%20kotlin.Int))`(`v:` `[View](/reference/kotlin/android/view/View)!`, `scrollX:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `scrollY:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `oldScrollX:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `oldScrollY:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Called when the scroll position of a view changes. |\n\nPublic methods\n--------------\n\n### onScrollChange\n\nAdded in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun onScrollChange(\n v: View!, \n scrollX: Int, \n scrollY: Int, \n oldScrollX: Int, \n oldScrollY: Int\n): Unit\n```\n\nCalled when the scroll position of a view changes.\n\n| Parameters ||\n|--------------|----------------------------------------------------------------------------------------------------------------|\n| `v` | [View](/reference/kotlin/android/view/View)!: The view whose scroll position has changed. |\n| `scrollX` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): Current horizontal scroll origin. |\n| `scrollY` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): Current vertical scroll origin. |\n| `oldScrollX` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): Previous horizontal scroll origin. |\n| `oldScrollY` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): Previous vertical scroll origin. |"]]