Stay organized with collections
Save and categorize content based on your preferences.
GraphemeClusterSegmentFinder
open class GraphemeClusterSegmentFinder : SegmentFinder
Implementation of SegmentFinder
using grapheme clusters as the text segment. Whitespace characters are included as segments.
For example, the text "a pot" would be divided into five text segments: "a", " ", "p", "o", "t".
Summary
Inherited constants |
From class SegmentFinder
Int |
DONE
Return value of previousStartBoundary(int), previousEndBoundary(int), nextStartBoundary(int), and nextEndBoundary(int) when there are no boundaries of the specified type in the specified direction.
|
|
Public constructors |
Constructs a GraphemeClusterSegmentFinder instance for the specified text which uses the provided TextPaint to determine grapheme cluster boundaries.
|
Public methods |
open Int |
Returns the character offset of the next text segment end boundary after the specified character offset, or DONE if there are none.
|
open Int |
Returns the character offset of the next text segment start boundary after the specified character offset, or DONE if there are none.
|
open Int |
Returns the character offset of the previous text segment end boundary before the specified character offset, or DONE if there are none.
|
open Int |
Returns the character offset of the previous text segment start boundary before the specified character offset, or DONE if there are none.
|
Public constructors
GraphemeClusterSegmentFinder
GraphemeClusterSegmentFinder(
text: CharSequence,
textPaint: TextPaint)
Constructs a GraphemeClusterSegmentFinder instance for the specified text which uses the provided TextPaint to determine grapheme cluster boundaries.
Parameters |
text |
CharSequence: text to be segmented This value cannot be null . |
textPaint |
TextPaint: TextPaint used to draw the text This value cannot be null . |
Public methods
nextEndBoundary
open fun nextEndBoundary(offset: Int): Int
Returns the character offset of the next text segment end boundary after the specified character offset, or DONE
if there are none.
Parameters |
offset |
Int: Value is 0 or greater |
nextStartBoundary
open fun nextStartBoundary(offset: Int): Int
Returns the character offset of the next text segment start boundary after the specified character offset, or DONE
if there are none.
Parameters |
offset |
Int: Value is 0 or greater |
previousEndBoundary
open fun previousEndBoundary(offset: Int): Int
Returns the character offset of the previous text segment end boundary before the specified character offset, or DONE
if there are none.
Parameters |
offset |
Int: Value is 0 or greater |
previousStartBoundary
open fun previousStartBoundary(offset: Int): Int
Returns the character offset of the previous text segment start boundary before the specified character offset, or DONE
if there are none.
Parameters |
offset |
Int: Value is 0 or greater |
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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# GraphemeClusterSegmentFinder\n\nAdded in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nGraphemeClusterSegmentFinder\n============================\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/text/GraphemeClusterSegmentFinder \"View this page in Java\") \n\n```\nopen class GraphemeClusterSegmentFinder : SegmentFinder\n```\n\n|---|---|------------------------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) |||\n| ↳ | [android.text.SegmentFinder](/reference/kotlin/android/text/SegmentFinder) ||\n| | ↳ | [android.text.GraphemeClusterSegmentFinder](#) |\n\nImplementation of `SegmentFinder` using grapheme clusters as the text segment. Whitespace characters are included as segments.\n\nFor example, the text \"a pot\" would be divided into five text segments: \"a\", \" \", \"p\", \"o\", \"t\".\n\nSummary\n-------\n\n| Inherited constants ||\n|---|---|\n| From class [SegmentFinder](/reference/kotlin/android/text/SegmentFinder) |----------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [DONE](/reference/kotlin/android/text/SegmentFinder#DONE:kotlin.Int) Return value of previousStartBoundary(int), previousEndBoundary(int), nextStartBoundary(int), and nextEndBoundary(int) when there are no boundaries of the specified type in the specified direction. \u003cbr /\u003e | ||\n\n| Public constructors ||\n|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|\n| [GraphemeClusterSegmentFinder](#GraphemeClusterSegmentFinder(kotlin.CharSequence,%20android.text.TextPaint))`(`text:` `[CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)`, `textPaint:` `[TextPaint](/reference/kotlin/android/text/TextPaint)`)` Constructs a GraphemeClusterSegmentFinder instance for the specified text which uses the provided TextPaint to determine grapheme cluster boundaries. |\n\n| Public methods ||\n|---------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| open [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [nextEndBoundary](#nextEndBoundary(kotlin.Int))`(`offset:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Returns the character offset of the next text segment end boundary after the specified character offset, or `DONE` if there are none. |\n| open [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [nextStartBoundary](#nextStartBoundary(kotlin.Int))`(`offset:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Returns the character offset of the next text segment start boundary after the specified character offset, or `DONE` if there are none. |\n| open [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [previousEndBoundary](#previousEndBoundary(kotlin.Int))`(`offset:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Returns the character offset of the previous text segment end boundary before the specified character offset, or `DONE` if there are none. |\n| open [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [previousStartBoundary](#previousStartBoundary(kotlin.Int))`(`offset:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Returns the character offset of the previous text segment start boundary before the specified character offset, or `DONE` if there are none. |\n\nPublic constructors\n-------------------\n\n### GraphemeClusterSegmentFinder\n\nAdded in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nGraphemeClusterSegmentFinder(\n text: CharSequence, \n textPaint: TextPaint)\n```\n\nConstructs a GraphemeClusterSegmentFinder instance for the specified text which uses the provided TextPaint to determine grapheme cluster boundaries.\n\n| Parameters ||\n|-------------|--------------------------------------------------------------------------------------------------------------------------------------------------|\n| `text` | [CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html): text to be segmented This value cannot be `null`. |\n| `textPaint` | [TextPaint](/reference/kotlin/android/text/TextPaint): TextPaint used to draw the text This value cannot be `null`. |\n\nPublic methods\n--------------\n\n### nextEndBoundary\n\nAdded in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun nextEndBoundary(offset: Int): Int\n```\n\nReturns the character offset of the next text segment end boundary after the specified character offset, or `DONE` if there are none.\n\n| Parameters ||\n|----------|---------------------------------------------------------------------------------------------------|\n| `offset` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): Value is 0 or greater |\n\n### nextStartBoundary\n\nAdded in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun nextStartBoundary(offset: Int): Int\n```\n\nReturns the character offset of the next text segment start boundary after the specified character offset, or `DONE` if there are none.\n\n| Parameters ||\n|----------|---------------------------------------------------------------------------------------------------|\n| `offset` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): Value is 0 or greater |\n\n### previousEndBoundary\n\nAdded in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun previousEndBoundary(offset: Int): Int\n```\n\nReturns the character offset of the previous text segment end boundary before the specified character offset, or `DONE` if there are none.\n\n| Parameters ||\n|----------|---------------------------------------------------------------------------------------------------|\n| `offset` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): Value is 0 or greater |\n\n### previousStartBoundary\n\nAdded in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun previousStartBoundary(offset: Int): Int\n```\n\nReturns the character offset of the previous text segment start boundary before the specified character offset, or `DONE` if there are none.\n\n| Parameters ||\n|----------|---------------------------------------------------------------------------------------------------|\n| `offset` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): Value is 0 or greater |"]]