Added in API level 1

DynamicLayout


open class DynamicLayout : Layout
kotlin.Any
   ↳ android.text.Layout
   ↳ android.text.DynamicLayout

DynamicLayout is a text layout that updates itself as the text is edited.

This is used by widgets to control text layout. You should not need to use this class directly unless you are implementing your own widget or custom display object, or need to call Canvas.drawText() directly.

Summary

Nested classes

Builder for dynamic layouts.

Inherited constants
Public constructors
DynamicLayout(base: CharSequence, paint: TextPaint, width: Int, align: Layout.Alignment, spacingmult: Float, spacingadd: Float, includepad: Boolean)

DynamicLayout(base: CharSequence, display: CharSequence, paint: TextPaint, width: Int, align: Layout.Alignment, spacingmult: Float, spacingadd: Float, includepad: Boolean)

DynamicLayout(base: CharSequence, display: CharSequence, paint: TextPaint, width: Int, align: Layout.Alignment, spacingmult: Float, spacingadd: Float, includepad: Boolean, ellipsize: TextUtils.TruncateAt?, ellipsizedWidth: Int)

Public methods
open Int

Returns the number of extra pixels of descent padding in the bottom line of the Layout.

open Int

Returns the number of characters to be ellipsized away, or 0 if no ellipsis is to take place.

open Int

Return the offset of the first character to be ellipsized away, relative to the start of the line.

open Int

Return the width to which this layout is ellipsized.

open LineBreakConfig

Gets the LineBreakConfig used in this DynamicLayout.

open Boolean

Returns whether the specified line contains one or more characters that need to be handled specially, like tabs.

open Int

Return the number of lines of text in this layout.

open Int

Return the descent of the specified line(0…getLineCount() - 1).

Layout.Directions!

Returns the directional run information for the specified line.

open Int

Return the text offset of the beginning of the specified line ( 0…getLineCount()).

open Int
getLineTop(line: Int)

Return the vertical position of the top of the specified line (0…getLineCount()).

open Int

Returns the primary directionality of the paragraph containing the specified line, either 1 for left-to-right lines, or -1 for right-to-left lines (see DIR_LEFT_TO_RIGHT, DIR_RIGHT_TO_LEFT).

open Int

Returns the (negative) number of extra pixels of ascent padding in the top line of the Layout.

Inherited functions
Inherited properties

Public constructors

DynamicLayout

Added in API level 1
DynamicLayout(
    base: CharSequence,
    paint: TextPaint,
    width: Int,
    align: Layout.Alignment,
    spacingmult: Float,
    spacingadd: Float,
    includepad: Boolean)

Deprecated: Use Builder instead.

Parameters
base CharSequence: This value cannot be null.
paint TextPaint: This value cannot be null.
width Int: Value is 0 or greater
align Layout.Alignment: This value cannot be null.
spacingmult Float: Value is 0.0f or greater

DynamicLayout

Added in API level 1
DynamicLayout(
    base: CharSequence,
    display: CharSequence,
    paint: TextPaint,
    width: Int,
    align: Layout.Alignment,
    spacingmult: Float,
    spacingadd: Float,
    includepad: Boolean)

Deprecated: Use Builder instead.

Parameters
base CharSequence: This value cannot be null.
display CharSequence: This value cannot be null.
paint TextPaint: This value cannot be null.
width Int: Value is 0 or greater
align Layout.Alignment: This value cannot be null.
spacingmult Float: Value is 0.0f or greater

DynamicLayout

Added in API level 1
DynamicLayout(
    base: CharSequence,
    display: CharSequence,
    paint: TextPaint,
    width: Int,
    align: Layout.Alignment,
    spacingmult: Float,
    spacingadd: Float,
    includepad: Boolean,
    ellipsize: TextUtils.TruncateAt?,
    ellipsizedWidth: Int)

Deprecated: Use Builder instead.

Parameters
base CharSequence: This value cannot be null.
display CharSequence: This value cannot be null.
paint TextPaint: This value cannot be null.
width Int: Value is 0 or greater
align Layout.Alignment: This value cannot be null.
spacingmult Float: Value is 0.0f or greater
ellipsize TextUtils.TruncateAt?: This value may be null.
ellipsizedWidth Int: Value is 0 or greater

Public methods

getBottomPadding

Added in API level 1
open fun getBottomPadding(): Int

Returns the number of extra pixels of descent padding in the bottom line of the Layout.

getEllipsisCount

Added in API level 1
open fun getEllipsisCount(line: Int): Int

Returns the number of characters to be ellipsized away, or 0 if no ellipsis is to take place.

getEllipsisStart

Added in API level 1
open fun getEllipsisStart(line: Int): Int

Return the offset of the first character to be ellipsized away, relative to the start of the line. (So 0 if the beginning of the line is ellipsized, not getLineStart().)

getEllipsizedWidth

Added in API level 1
open fun getEllipsizedWidth(): Int

Return the width to which this layout is ellipsized. If no ellipsize is applied, the same amount of getWidth is returned.

Return
Int the amount of ellipsized width in pixels.
Value is 0 or greater

getLineBreakConfig

Added in API level 35
open fun getLineBreakConfig(): LineBreakConfig

Gets the LineBreakConfig used in this DynamicLayout. Use this only to consult the LineBreakConfig's properties and not to change them.

Return
LineBreakConfig The line break config in this DynamicLayout.
This value cannot be null.

getLineContainsTab

Added in API level 1
open fun getLineContainsTab(line: Int): Boolean

Returns whether the specified line contains one or more characters that need to be handled specially, like tabs.

getLineCount

Added in API level 1
open fun getLineCount(): Int

Return the number of lines of text in this layout.

getLineDescent

Added in API level 1
open fun getLineDescent(line: Int): Int

Return the descent of the specified line(0…getLineCount() - 1).

getLineDirections

Added in API level 1
fun getLineDirections(line: Int): Layout.Directions!

Returns the directional run information for the specified line. The array alternates counts of characters in left-to-right and right-to-left segments of the line.

NOTE: this is inadequate to support bidirectional text, and will change.

getLineStart

Added in API level 1
open fun getLineStart(line: Int): Int

Return the text offset of the beginning of the specified line ( 0…getLineCount()). If the specified line is equal to the line count, returns the length of the text.

getLineTop

Added in API level 1
open fun getLineTop(line: Int): Int

Return the vertical position of the top of the specified line (0…getLineCount()). If the specified line is equal to the line count, returns the bottom of the last line.

getParagraphDirection

Added in API level 1
open fun getParagraphDirection(line: Int): Int

Returns the primary directionality of the paragraph containing the specified line, either 1 for left-to-right lines, or -1 for right-to-left lines (see DIR_LEFT_TO_RIGHT, DIR_RIGHT_TO_LEFT).

getTopPadding

Added in API level 1
open fun getTopPadding(): Int

Returns the (negative) number of extra pixels of ascent padding in the top line of the Layout.