Stay organized with collections
Save and categorize content based on your preferences.
Touch
open class Touch
Summary
Public methods |
open static Int |
|
open static Int |
|
open static Boolean |
Handles touch events for dragging.
|
open static Unit |
Scrolls the specified widget to the specified coordinates, except constrains the X scrolling position to the horizontal regions of the text that will be visible after scrolling to the specified Y position.
|
Public methods
onTouchEvent
open static fun onTouchEvent(
widget: TextView!,
buffer: Spannable!,
event: MotionEvent!
): Boolean
Handles touch events for dragging. You may want to do other actions like moving the cursor on touch as well.
open static fun scrollTo(
widget: TextView!,
layout: Layout!,
x: Int,
y: Int
): Unit
Scrolls the specified widget to the specified coordinates, except constrains the X scrolling position to the horizontal regions of the text that will be visible after scrolling to the specified Y position.
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,["# Touch\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nTouch\n=====\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/text/method/Touch \"View this page in Java\") \n\n```\nopen class Touch\n```\n\n|---|--------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [android.text.method.Touch](#) |\n\nSummary\n-------\n\n| Public methods ||\n|------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| open static [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [getInitialScrollX](#getInitialScrollX(android.widget.TextView,%20android.text.Spannable))`(`widget:` `[TextView](../../widget/TextView.html#)!`, `buffer:` `[Spannable](../Spannable.html#)!`)` \u003cbr /\u003e |\n| open static [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [getInitialScrollY](#getInitialScrollY(android.widget.TextView,%20android.text.Spannable))`(`widget:` `[TextView](../../widget/TextView.html#)!`, `buffer:` `[Spannable](../Spannable.html#)!`)` \u003cbr /\u003e |\n| open static [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [onTouchEvent](#onTouchEvent(android.widget.TextView,%20android.text.Spannable,%20android.view.MotionEvent))`(`widget:` `[TextView](../../widget/TextView.html#)!`, `buffer:` `[Spannable](../Spannable.html#)!`, `event:` `[MotionEvent](../../view/MotionEvent.html#)!`)` Handles touch events for dragging. |\n| open static [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [scrollTo](#scrollTo(android.widget.TextView,%20android.text.Layout,%20kotlin.Int,%20kotlin.Int))`(`widget:` `[TextView](../../widget/TextView.html#)!`, `layout:` `[Layout](../Layout.html#)!`, `x:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `y:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Scrolls the specified widget to the specified coordinates, except constrains the X scrolling position to the horizontal regions of the text that will be visible after scrolling to the specified Y position. |\n\nPublic methods\n--------------\n\n### getInitialScrollX\n\nAdded in [API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen static fun getInitialScrollX(\n widget: TextView!, \n buffer: Spannable!\n): Int\n```\n\n| Parameters ||\n|----------|----------------------------------------------------------|\n| `widget` | [TextView](../../widget/TextView.html#)!: The text view. |\n| `buffer` | [Spannable](../Spannable.html#)!: The text buffer. |\n\n### getInitialScrollY\n\nAdded in [API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen static fun getInitialScrollY(\n widget: TextView!, \n buffer: Spannable!\n): Int\n```\n\n| Parameters ||\n|----------|----------------------------------------------------------|\n| `widget` | [TextView](../../widget/TextView.html#)!: The text view. |\n| `buffer` | [Spannable](../Spannable.html#)!: The text buffer. |\n\n### onTouchEvent\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen static fun onTouchEvent(\n widget: TextView!, \n buffer: Spannable!, \n event: MotionEvent!\n): Boolean\n```\n\nHandles touch events for dragging. You may want to do other actions like moving the cursor on touch as well. \n\n### scrollTo\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen static fun scrollTo(\n widget: TextView!, \n layout: Layout!, \n x: Int, \n y: Int\n): Unit\n```\n\nScrolls the specified widget to the specified coordinates, except constrains the X scrolling position to the horizontal regions of the text that will be visible after scrolling to the specified Y position."]]