Stay organized with collections
Save and categorize content based on your preferences.
Standard
open class Standard : AlignmentSpan, ParcelableSpan
Default implementation of the AlignmentSpan
.
For example, a text written in a left to right language, like English, which is by default aligned to the left, can be aligned opposite to the layout direction like this:
<code>SpannableString string = new SpannableString("Text with opposite alignment");
string.setSpan(new AlignmentSpan.Standard(Layout.Alignment.ALIGN_OPPOSITE), 0,
string.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);</code>
Align left to right text opposite to the layout direction.
A text written in a right to left language, like Hebrew, which is by default aligned to the right, can be aligned opposite to the layout direction like this:
<code>SpannableString string = new SpannableString("טקסט עם יישור הפוך");
string.setSpan(new AlignmentSpan.Standard(Layout.Alignment.ALIGN_OPPOSITE), 0,
string.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);</code>
Align right to left text opposite to the layout direction.
Summary
Public constructors |
Constructs a Standard from a parcel.
|
Constructs a Standard from an alignment.
|
Public constructors
Standard
Standard(src: Parcel)
Constructs a Standard
from a parcel.
Parameters |
src |
Parcel: This value cannot be null . |
Public methods
describeContents
open fun describeContents(): Int
getSpanTypeId
open fun getSpanTypeId(): Int
toString
open fun toString(): String
Return |
String |
a string representation of the object. |
writeToParcel
open fun writeToParcel(
dest: Parcel,
flags: Int
): Unit
Flatten this object in to a Parcel.
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,["# AlignmentSpan.Standard\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nStandard\n========\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/text/style/AlignmentSpan.Standard \"View this page in Java\") \n\n```\nopen class Standard : AlignmentSpan, ParcelableSpan\n```\n\n|---|------------------------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [android.text.style.AlignmentSpan.Standard](#) |\n\nDefault implementation of the [AlignmentSpan](/reference/kotlin/android/text/style/AlignmentSpan).\n\nFor example, a text written in a left to right language, like English, which is by default aligned to the left, can be aligned opposite to the layout direction like this: \n\n```kotlin\n\u003ccode\u003eSpannableString string = new SpannableString(\"Text with opposite alignment\");\n string.setSpan(new AlignmentSpan.Standard(Layout.Alignment.ALIGN_OPPOSITE), 0,\n string.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);\u003c/code\u003e\n```\nAlign left to right text opposite to the layout direction.\n\nA text written in a right to left language, like Hebrew, which is by default aligned to the right, can be aligned opposite to the layout direction like this: \n\n```kotlin\n\u003ccode\u003eSpannableString string = new SpannableString(\"טקסט עם יישור הפוך\");\n string.setSpan(new AlignmentSpan.Standard(Layout.Alignment.ALIGN_OPPOSITE), 0,\n string.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);\u003c/code\u003e\n```\nAlign right to left text opposite to the layout direction.\n\nSummary\n-------\n\n| Public constructors ||\n|----------------------------------------------------------------------------------------------------------------------------------------------------------------|---|\n| [Standard](#Standard(android.os.Parcel))`(`src:` `[Parcel](../../os/Parcel.html#)`)` Constructs a [Standard](#) from a parcel. |\n| [Standard](#Standard(android.text.Layout.Alignment))`(`align:` `[Layout.Alignment](../Layout.Alignment.html#)`)` Constructs a [Standard](#) from an alignment. |\n\n| Public methods ||\n|---------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| open [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [describeContents](#describeContents())`()` \u003cbr /\u003e |\n| open [Layout.Alignment](../Layout.Alignment.html#)! | [getAlignment](#getAlignment())`()` \u003cbr /\u003e |\n| open [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [getSpanTypeId](#getSpanTypeId())`()` \u003cbr /\u003e |\n| open [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | [toString](#toString())`()` \u003cbr /\u003e |\n| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [writeToParcel](#writeToParcel(android.os.Parcel,%20kotlin.Int))`(`dest:` `[Parcel](../../os/Parcel.html#)`, `flags:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Flatten this object in to a Parcel. |\n\nPublic constructors\n-------------------\n\n### Standard\n\nAdded in [API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nStandard(src: Parcel)\n```\n\nConstructs a [Standard](#) from a parcel.\n\n| Parameters ||\n|-------|---------------------------------------------------------------|\n| `src` | [Parcel](../../os/Parcel.html#): This value cannot be `null`. |\n\n### Standard\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nStandard(align: Layout.Alignment)\n```\n\nConstructs a [Standard](#) from an alignment.\n\n| Parameters ||\n|---------|-----------------------------------------------------------------------------|\n| `align` | [Layout.Alignment](../Layout.Alignment.html#): This value cannot be `null`. |\n\nPublic methods\n--------------\n\n### describeContents\n\nAdded in [API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun describeContents(): Int\n```\n\n| Return ||\n|----------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either `0` or [android.os.Parcelable#CONTENTS_FILE_DESCRIPTOR](../../os/Parcelable.html#CONTENTS_FILE_DESCRIPTOR:kotlin.Int) |\n\n### getAlignment\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun getAlignment(): Layout.Alignment!\n```\n\n| Return ||\n|------------------------------------------------|--------------------|\n| [Layout.Alignment](../Layout.Alignment.html#)! | the text alignment |\n\n### getSpanTypeId\n\nAdded in [API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun getSpanTypeId(): Int\n``` \n\n### toString\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun toString(): String\n```\n\n| Return ||\n|----------------------------------------------------------------------------------|----------------------------------------|\n| [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | a string representation of the object. |\n\n### writeToParcel\n\nAdded in [API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun writeToParcel(\n dest: Parcel, \n flags: Int\n): Unit\n```\n\nFlatten this object in to a Parcel.\n\n| Parameters ||\n|---------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `dest` | [Parcel](../../os/Parcel.html#): This value cannot be `null`. |\n| `flags` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): Additional flags about how the object should be written. May be 0 or [PARCELABLE_WRITE_RETURN_VALUE](../../os/Parcelable.html#PARCELABLE_WRITE_RETURN_VALUE:kotlin.Int). Value is either `0` or a combination of [android.os.Parcelable#PARCELABLE_WRITE_RETURN_VALUE](../../os/Parcelable.html#PARCELABLE_WRITE_RETURN_VALUE:kotlin.Int), and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES |"]]