Stay organized with collections
Save and categorize content based on your preferences.
TextStyle
class TextStyle
Enumeration of the style of text formatting and parsing.
Text styles define three sizes for the formatted text - 'full', 'short' and 'narrow'. Each of these three sizes is available in both 'standard' and 'stand-alone' variations.
The difference between the three sizes is obvious in most languages. For example, in English the 'full' month is 'January', the 'short' month is 'Jan' and the 'narrow' month is 'J'. Note that the narrow size is often not unique. For example, 'January', 'June' and 'July' all have the 'narrow' text 'J'.
The difference between the 'standard' and 'stand-alone' forms is trickier to describe as there is no difference in English. However, in other languages there is a difference in the word used when the text is used alone, as opposed to in a complete date. For example, the word used for a month when used alone in a date picker is different to the word used for month in association with a day and year in a date.
Summary
Enum values |
Full text, typically the full description.
|
Full text for stand-alone use, typically the full description.
|
Narrow text, typically a single letter.
|
Narrow text for stand-alone use, typically a single letter.
|
Short text, typically an abbreviation.
|
Short text for stand-alone use, typically an abbreviation.
|
Public methods |
TextStyle! |
Returns the normal style with the same size.
|
TextStyle! |
Returns the stand-alone style with the same size.
|
Boolean |
Returns true if the Style is a stand-alone style.
|
Enum values
FULL
enum val FULL : TextStyle
Full text, typically the full description. For example, day-of-week Monday might output "Monday".
FULL_STANDALONE
enum val FULL_STANDALONE : TextStyle
Full text for stand-alone use, typically the full description. For example, day-of-week Monday might output "Monday".
NARROW
enum val NARROW : TextStyle
Narrow text, typically a single letter. For example, day-of-week Monday might output "M".
NARROW_STANDALONE
enum val NARROW_STANDALONE : TextStyle
Narrow text for stand-alone use, typically a single letter. For example, day-of-week Monday might output "M".
SHORT
enum val SHORT : TextStyle
Short text, typically an abbreviation. For example, day-of-week Monday might output "Mon".
SHORT_STANDALONE
enum val SHORT_STANDALONE : TextStyle
Short text for stand-alone use, typically an abbreviation. For example, day-of-week Monday might output "Mon".
Public methods
asNormal
fun asNormal(): TextStyle!
Returns the normal style with the same size.
Return |
TextStyle! |
the normal style with the same size |
asStandalone
fun asStandalone(): TextStyle!
Returns the stand-alone style with the same size.
Return |
TextStyle! |
the stand-alone style with the same size |
isStandalone
fun isStandalone(): Boolean
Returns true if the Style is a stand-alone style.
Return |
Boolean |
true if the style is a stand-alone style. |
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,["# TextStyle\n\nAdded in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nTextStyle\n=========\n\n```\nclass TextStyle\n```\n\n|---|---|---------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) |||\n| ↳ | [kotlin.Enum](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-enum/index.html)\\\u003c[java.time.format.TextStyle](#)\\\u003e ||\n| | ↳ | [java.time.format.TextStyle](#) |\n\n|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Known Direct Subclasses [TextStyle.FULL](#ENUM_VALUE:FULL), [TextStyle.FULL_STANDALONE](#ENUM_VALUE:FULL_STANDALONE), [TextStyle.NARROW](#ENUM_VALUE:NARROW), [TextStyle.NARROW_STANDALONE](#ENUM_VALUE:NARROW_STANDALONE), [TextStyle.SHORT](#ENUM_VALUE:SHORT), [TextStyle.SHORT_STANDALONE](#ENUM_VALUE:SHORT_STANDALONE) |--------------------------------------------------------------|----------------------------------------------------------------| | [TextStyle.FULL](#ENUM_VALUE:FULL) | Full text, typically the full description. | | [TextStyle.FULL_STANDALONE](#ENUM_VALUE:FULL_STANDALONE) | Full text for stand-alone use, typically the full description. | | [TextStyle.NARROW](#ENUM_VALUE:NARROW) | Narrow text, typically a single letter. | | [TextStyle.NARROW_STANDALONE](#ENUM_VALUE:NARROW_STANDALONE) | Narrow text for stand-alone use, typically a single letter. | | [TextStyle.SHORT](#ENUM_VALUE:SHORT) | Short text, typically an abbreviation. | | [TextStyle.SHORT_STANDALONE](#ENUM_VALUE:SHORT_STANDALONE) | Short text for stand-alone use, typically an abbreviation. | |\n\nEnumeration of the style of text formatting and parsing.\n\nText styles define three sizes for the formatted text - 'full', 'short' and 'narrow'. Each of these three sizes is available in both 'standard' and 'stand-alone' variations.\n\nThe difference between the three sizes is obvious in most languages. For example, in English the 'full' month is 'January', the 'short' month is 'Jan' and the 'narrow' month is 'J'. Note that the narrow size is often not unique. For example, 'January', 'June' and 'July' all have the 'narrow' text 'J'.\n\nThe difference between the 'standard' and 'stand-alone' forms is trickier to describe as there is no difference in English. However, in other languages there is a difference in the word used when the text is used alone, as opposed to in a complete date. For example, the word used for a month when used alone in a date picker is different to the word used for month in association with a day and year in a date.\n\nSummary\n-------\n\n| Enum values ||\n|----------------------------------------------------------------------------------------------------------------|---|\n| [FULL](#ENUM_VALUE:FULL) Full text, typically the full description. |\n| [FULL_STANDALONE](#ENUM_VALUE:FULL_STANDALONE) Full text for stand-alone use, typically the full description. |\n| [NARROW](#ENUM_VALUE:NARROW) Narrow text, typically a single letter. |\n| [NARROW_STANDALONE](#ENUM_VALUE:NARROW_STANDALONE) Narrow text for stand-alone use, typically a single letter. |\n| [SHORT](#ENUM_VALUE:SHORT) Short text, typically an abbreviation. |\n| [SHORT_STANDALONE](#ENUM_VALUE:SHORT_STANDALONE) Short text for stand-alone use, typically an abbreviation. |\n\n| Public methods ||\n|------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------|\n| [TextStyle](#)! | [asNormal](#asNormal())`()` Returns the normal style with the same size. |\n| [TextStyle](#)! | [asStandalone](#asStandalone())`()` Returns the stand-alone style with the same size. |\n| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [isStandalone](#isStandalone())`()` Returns true if the Style is a stand-alone style. |\n\nEnum values\n-----------\n\n### FULL\n\nAdded in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nenum val FULL : TextStyle\n```\n\nFull text, typically the full description. For example, day-of-week Monday might output \"Monday\". \n\n### FULL_STANDALONE\n\nAdded in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nenum val FULL_STANDALONE : TextStyle\n```\n\nFull text for stand-alone use, typically the full description. For example, day-of-week Monday might output \"Monday\". \n\n### NARROW\n\nAdded in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nenum val NARROW : TextStyle\n```\n\nNarrow text, typically a single letter. For example, day-of-week Monday might output \"M\". \n\n### NARROW_STANDALONE\n\nAdded in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nenum val NARROW_STANDALONE : TextStyle\n```\n\nNarrow text for stand-alone use, typically a single letter. For example, day-of-week Monday might output \"M\". \n\n### SHORT\n\nAdded in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nenum val SHORT : TextStyle\n```\n\nShort text, typically an abbreviation. For example, day-of-week Monday might output \"Mon\". \n\n### SHORT_STANDALONE\n\nAdded in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nenum val SHORT_STANDALONE : TextStyle\n```\n\nShort text for stand-alone use, typically an abbreviation. For example, day-of-week Monday might output \"Mon\".\n\nPublic methods\n--------------\n\n### asNormal\n\nAdded in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun asNormal(): TextStyle!\n```\n\nReturns the normal style with the same size.\n\n| Return ||\n|-----------------|-------------------------------------|\n| [TextStyle](#)! | the normal style with the same size |\n\n### asStandalone\n\nAdded in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun asStandalone(): TextStyle!\n```\n\nReturns the stand-alone style with the same size.\n\n| Return ||\n|-----------------|------------------------------------------|\n| [TextStyle](#)! | the stand-alone style with the same size |\n\n### isStandalone\n\nAdded in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun isStandalone(): Boolean\n```\n\nReturns true if the Style is a stand-alone style.\n\n| Return ||\n|------------------------------------------------------------------------------------|-------------------------------------------|\n| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | true if the style is a stand-alone style. |"]]