Stay organized with collections
Save and categorize content based on your preferences.
TextDirectionHeuristics
open class TextDirectionHeuristics
Some objects that implement TextDirectionHeuristic
. Use these with the android.text.BidiFormatter#unicodeWrap methods in BidiFormatter
. Also notice that these direction heuristics correspond to the same types of constants provided in the android.view.View
class for setTextDirection()
, such as android.view.View#TEXT_DIRECTION_RTL
.
To support versions lower than android.os.Build.VERSION_CODES#JELLY_BEAN_MR2
, you can use the support library's androidx.core.text.TextDirectionHeuristicsCompat class.
Summary
Properties |
static TextDirectionHeuristic! |
If the text contains any strong right to left non-format character, determines that the direction is right to left, falling back to left to right if it finds none.
|
static TextDirectionHeuristic! |
Determines the direction based on the first strong directional character, including bidi format chars, falling back to left to right if it finds none.
|
static TextDirectionHeuristic! |
Determines the direction based on the first strong directional character, including bidi format chars, falling back to right to left if it finds none.
|
static TextDirectionHeuristic! |
Force the paragraph direction to the Locale direction.
|
static TextDirectionHeuristic! |
Always decides that the direction is left to right.
|
static TextDirectionHeuristic! |
Always decides that the direction is right to left.
|
Public constructors
TextDirectionHeuristics
TextDirectionHeuristics()
Properties
ANYRTL_LTR
static val ANYRTL_LTR: TextDirectionHeuristic!
If the text contains any strong right to left non-format character, determines that the direction is right to left, falling back to left to right if it finds none.
FIRSTSTRONG_LTR
static val FIRSTSTRONG_LTR: TextDirectionHeuristic!
Determines the direction based on the first strong directional character, including bidi format chars, falling back to left to right if it finds none. This is the default behavior of the Unicode Bidirectional Algorithm.
FIRSTSTRONG_RTL
static val FIRSTSTRONG_RTL: TextDirectionHeuristic!
Determines the direction based on the first strong directional character, including bidi format chars, falling back to right to left if it finds none. This is similar to the default behavior of the Unicode Bidirectional Algorithm, just with different fallback behavior.
LOCALE
static val LOCALE: TextDirectionHeuristic!
Force the paragraph direction to the Locale direction. Falls back to left to right.
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,["# TextDirectionHeuristics\n\nAdded in [API level 18](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nTextDirectionHeuristics\n=======================\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/text/TextDirectionHeuristics \"View this page in Java\") \n\n```\nopen class TextDirectionHeuristics\n```\n\n|---|-------------------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [android.text.TextDirectionHeuristics](#) |\n\nSome objects that implement [TextDirectionHeuristic](/reference/kotlin/android/text/TextDirectionHeuristic). Use these with the android.text.BidiFormatter#unicodeWrap methods in [BidiFormatter](/reference/kotlin/android/text/BidiFormatter). Also notice that these direction heuristics correspond to the same types of constants provided in the [android.view.View](../view/View.html#) class for [setTextDirection()](../view/View.html#setTextDirection(kotlin.Int)), such as [android.view.View#TEXT_DIRECTION_RTL](../view/View.html#TEXT_DIRECTION_RTL:kotlin.Int).\n\nTo support versions lower than [android.os.Build.VERSION_CODES#JELLY_BEAN_MR2](../os/Build.VERSION_CODES.html#JELLY_BEAN_MR2:kotlin.Int), you can use the support library's androidx.core.text.TextDirectionHeuristicsCompat class.\n\nSummary\n-------\n\n| Public constructors ||\n|------------------------------------------------------------------|---|\n| [TextDirectionHeuristics](#TextDirectionHeuristics())`()` \u003cbr /\u003e |\n\n| Properties ||\n|-----------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| static [TextDirectionHeuristic](/reference/kotlin/android/text/TextDirectionHeuristic)! | [ANYRTL_LTR](#ANYRTL_LTR:android.text.TextDirectionHeuristic) If the text contains any strong right to left non-format character, determines that the direction is right to left, falling back to left to right if it finds none. |\n| static [TextDirectionHeuristic](/reference/kotlin/android/text/TextDirectionHeuristic)! | [FIRSTSTRONG_LTR](#FIRSTSTRONG_LTR:android.text.TextDirectionHeuristic) Determines the direction based on the first strong directional character, including bidi format chars, falling back to left to right if it finds none. |\n| static [TextDirectionHeuristic](/reference/kotlin/android/text/TextDirectionHeuristic)! | [FIRSTSTRONG_RTL](#FIRSTSTRONG_RTL:android.text.TextDirectionHeuristic) Determines the direction based on the first strong directional character, including bidi format chars, falling back to right to left if it finds none. |\n| static [TextDirectionHeuristic](/reference/kotlin/android/text/TextDirectionHeuristic)! | [LOCALE](#LOCALE:android.text.TextDirectionHeuristic) Force the paragraph direction to the Locale direction. |\n| static [TextDirectionHeuristic](/reference/kotlin/android/text/TextDirectionHeuristic)! | [LTR](#LTR:android.text.TextDirectionHeuristic) Always decides that the direction is left to right. |\n| static [TextDirectionHeuristic](/reference/kotlin/android/text/TextDirectionHeuristic)! | [RTL](#RTL:android.text.TextDirectionHeuristic) Always decides that the direction is right to left. |\n\nPublic constructors\n-------------------\n\n### TextDirectionHeuristics\n\n```\nTextDirectionHeuristics()\n```\n\nProperties\n----------\n\n### ANYRTL_LTR\n\nAdded in [API level 18](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nstatic val ANYRTL_LTR: TextDirectionHeuristic!\n```\n\nIf the text contains any strong right to left non-format character, determines that the direction is right to left, falling back to left to right if it finds none. \n\n### FIRSTSTRONG_LTR\n\nAdded in [API level 18](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nstatic val FIRSTSTRONG_LTR: TextDirectionHeuristic!\n```\n\nDetermines the direction based on the first strong directional character, including bidi format chars, falling back to left to right if it finds none. This is the default behavior of the Unicode Bidirectional Algorithm. \n\n### FIRSTSTRONG_RTL\n\nAdded in [API level 18](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nstatic val FIRSTSTRONG_RTL: TextDirectionHeuristic!\n```\n\nDetermines the direction based on the first strong directional character, including bidi format chars, falling back to right to left if it finds none. This is similar to the default behavior of the Unicode Bidirectional Algorithm, just with different fallback behavior. \n\n### LOCALE\n\nAdded in [API level 18](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nstatic val LOCALE: TextDirectionHeuristic!\n```\n\nForce the paragraph direction to the Locale direction. Falls back to left to right. \n\n### LTR\n\nAdded in [API level 18](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nstatic val LTR: TextDirectionHeuristic!\n```\n\nAlways decides that the direction is left to right. \n\n### RTL\n\nAdded in [API level 18](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nstatic val RTL: TextDirectionHeuristic!\n```\n\nAlways decides that the direction is right to left."]]