BoringLayout
open class BoringLayout : Layout, TextUtils.EllipsizeCallback
kotlin.Any | ||
↳ | android.text.Layout | |
↳ | android.text.BoringLayout |
A BoringLayout is a very simple Layout implementation for text that fits on a single line and is all left-to-right characters. You will probably never want to make one of these yourself; if you do, be sure to call #isBoring first to make sure the text meets the criteria.
This class 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, in which case you are encouraged to use a Layout instead of calling Canvas.drawText()
directly.
Summary
Nested classes | |
---|---|
open |
Inherited constants | |
---|---|
Public constructors | |
---|---|
BoringLayout(source: CharSequence!, paint: TextPaint!, outerwidth: Int, align: Layout.Alignment!, spacingMult: Float, spacingAdd: Float, metrics: BoringLayout.Metrics!, includePad: Boolean) |
|
BoringLayout(source: CharSequence!, paint: TextPaint!, outerWidth: Int, align: Layout.Alignment!, spacingMult: Float, spacingAdd: Float, metrics: BoringLayout.Metrics!, includePad: Boolean, ellipsize: TextUtils.TruncateAt!, ellipsizedWidth: Int) |
|
BoringLayout(source: CharSequence, paint: TextPaint, outerWidth: Int, align: Layout.Alignment, spacingMult: Float, spacingAdd: Float, metrics: BoringLayout.Metrics, includePad: Boolean, ellipsize: TextUtils.TruncateAt?, ellipsizedWidth: Int, useFallbackLineSpacing: Boolean) |
Public methods | |
---|---|
open RectF |
Get an actual bounding box that draws text content. |
open Unit | |
open Unit |
ellipsized(start: Int, end: Int) Callback for the ellipsizer to report what region it ellipsized. |
open Int | |
open Int |
getEllipsisCount(line: Int) |
open Int |
getEllipsisStart(line: Int) |
open Int | |
open Int | |
open Boolean |
getLineContainsTab(line: Int) |
open Int | |
open Int |
getLineDescent(line: Int) |
Layout.Directions! |
getLineDirections(line: Int) |
open Float |
getLineMax(line: Int) |
open Int |
getLineStart(line: Int) |
open Int |
getLineTop(line: Int) |
open Float |
getLineWidth(line: Int) |
open Int |
getParagraphDirection(line: Int) |
open Int | |
open static BoringLayout.Metrics! |
isBoring(text: CharSequence!, paint: TextPaint!) Determine and compute metrics if given text can be handled by BoringLayout. |
open static BoringLayout.Metrics! |
isBoring(text: CharSequence!, paint: TextPaint!, metrics: BoringLayout.Metrics!) Determine and compute metrics if given text can be handled by BoringLayout. |
open static BoringLayout.Metrics? |
isBoring(text: CharSequence, paint: TextPaint, textDir: TextDirectionHeuristic, useFallbackLineSpacing: Boolean, metrics: BoringLayout.Metrics?) Returns null if not boring; the width, ascent, and descent in the provided Metrics object (or a new one if the provided one was null) if boring. |
open Boolean | |
open static BoringLayout! |
make(source: CharSequence!, paint: TextPaint!, outerWidth: Int, align: Layout.Alignment!, spacingMult: Float, spacingAdd: Float, metrics: BoringLayout.Metrics!, includePad: Boolean) Utility function to construct a BoringLayout instance. |
open static BoringLayout! |
make(source: CharSequence!, paint: TextPaint!, outerWidth: Int, align: Layout.Alignment!, spacingmult: Float, spacingadd: Float, metrics: BoringLayout.Metrics!, includePad: Boolean, ellipsize: TextUtils.TruncateAt!, ellipsizedWidth: Int) Utility function to construct a BoringLayout instance. |
open static BoringLayout |
make(source: CharSequence, paint: TextPaint, outerWidth: Int, align: Layout.Alignment, metrics: BoringLayout.Metrics, includePad: Boolean, ellipsize: TextUtils.TruncateAt?, ellipsizedWidth: Int, useFallbackLineSpacing: Boolean) Utility function to construct a BoringLayout instance. |
open BoringLayout! |
replaceOrMake(source: CharSequence!, paint: TextPaint!, outerwidth: Int, align: Layout.Alignment!, spacingMult: Float, spacingAdd: Float, metrics: BoringLayout.Metrics!, includePad: Boolean) Returns a BoringLayout for the specified text, potentially reusing this one if it is already suitable. |
open BoringLayout |
replaceOrMake(source: CharSequence, paint: TextPaint, outerWidth: Int, align: Layout.Alignment, metrics: BoringLayout.Metrics, includePad: Boolean, ellipsize: TextUtils.TruncateAt?, ellipsizedWidth: Int, useFallbackLineSpacing: Boolean) Returns a BoringLayout for the specified text, potentially reusing this one if it is already suitable. |
open BoringLayout! |
replaceOrMake(source: CharSequence!, paint: TextPaint!, outerWidth: Int, align: Layout.Alignment!, spacingMult: Float, spacingAdd: Float, metrics: BoringLayout.Metrics!, includePad: Boolean, ellipsize: TextUtils.TruncateAt!, ellipsizedWidth: Int) Returns a BoringLayout for the specified text, potentially reusing this one if it is already suitable. |
Inherited functions | |
---|---|
Inherited properties | |
---|---|
Public constructors
BoringLayout
BoringLayout(
source: CharSequence!,
paint: TextPaint!,
outerwidth: Int,
align: Layout.Alignment!,
spacingMult: Float,
spacingAdd: Float,
metrics: BoringLayout.Metrics!,
includePad: Boolean)
Parameters | |
---|---|
source |
CharSequence!: the text to render |
paint |
TextPaint!: the default paint for the layout |
outerwidth |
Int: the wrapping width for the text |
align |
Layout.Alignment!: whether to left, right, or center the text |
spacingMult |
Float: this value is no longer used by BoringLayout |
spacingAdd |
Float: this value is no longer used by BoringLayout |
metrics |
BoringLayout.Metrics!: Metrics instance that contains information about FontMetrics and line width |
includePad |
Boolean: set whether to include extra space beyond font ascent and descent which is needed to avoid clipping in some scripts |
BoringLayout
BoringLayout(
source: CharSequence!,
paint: TextPaint!,
outerWidth: Int,
align: Layout.Alignment!,
spacingMult: Float,
spacingAdd: Float,
metrics: BoringLayout.Metrics!,
includePad: Boolean,
ellipsize: TextUtils.TruncateAt!,
ellipsizedWidth: Int)
Parameters | |
---|---|
source |
CharSequence!: the text to render |
paint |
TextPaint!: the default paint for the layout |
outerWidth |
Int: the wrapping width for the text |
align |
Layout.Alignment!: whether to left, right, or center the text |
spacingMult |
Float: this value is no longer used by BoringLayout |
spacingAdd |
Float: this value is no longer used by BoringLayout |
metrics |
BoringLayout.Metrics!: Metrics instance that contains information about FontMetrics and line width |
includePad |
Boolean: set whether to include extra space beyond font ascent and descent which is needed to avoid clipping in some scripts |
ellipsize |
TextUtils.TruncateAt!: whether to ellipsize the text if width of the text is longer than the requested outerWidth |
ellipsizedWidth |
Int: the width to which this Layout is ellipsizing. If ellipsize is null , or is TextUtils.TruncateAt#MARQUEE this value is not used, outerWidth is used instead |
BoringLayout
BoringLayout(
source: CharSequence,
paint: TextPaint,
outerWidth: Int,
align: Layout.Alignment,
spacingMult: Float,
spacingAdd: Float,
metrics: BoringLayout.Metrics,
includePad: Boolean,
ellipsize: TextUtils.TruncateAt?,
ellipsizedWidth: Int,
useFallbackLineSpacing: Boolean)
Parameters | |
---|---|
source |
CharSequence: the text to render This value cannot be null . |
paint |
TextPaint: the default paint for the layout This value cannot be null . |
outerWidth |
Int: the wrapping width for the text Value is 0 or greater |
align |
Layout.Alignment: whether to left, right, or center the text This value cannot be null . |
spacingMult |
Float: this value is no longer used by BoringLayout |
spacingAdd |
Float: this value is no longer used by BoringLayout |
metrics |
BoringLayout.Metrics: Metrics instance that contains information about FontMetrics and line width This value cannot be null . |
includePad |
Boolean: set whether to include extra space beyond font ascent and descent which is needed to avoid clipping in some scripts |
ellipsize |
TextUtils.TruncateAt?: whether to ellipsize the text if width of the text is longer than the requested outerWidth . null if ellipsis is not applied. |
ellipsizedWidth |
Int: the width to which this Layout is ellipsizing. If ellipsize is null , or is TextUtils.TruncateAt#MARQUEE this value is not used, outerWidth is used instead Value is 0 or greater |
useFallbackLineSpacing |
Boolean: True for adjusting the line spacing based on fallback fonts. False for keeping the first font's line height. If some glyphs requires larger vertical spaces, by passing true to this argument, the layout increase the line height to fit all glyphs. |
Public methods
computeDrawingBoundingBox
open fun computeDrawingBoundingBox(): RectF
Get an actual bounding box that draws text content. Note that the RectF#top
and RectF#bottom
may be different from the Layout#getLineTop(int)
of the first line and Layout#getLineBottom(int)
of the last line. The line top and line bottom are calculated based on yMin/yMax or ascent/descent value of font file. On the other hand, the drawing bounding boxes are calculated based on actual glyphs used there.
Return | |
---|---|
RectF |
This value cannot be null . |
draw
open fun draw(
c: Canvas!,
highlight: Path!,
highlightpaint: Paint!,
cursorOffset: Int
): Unit
Parameters | |
---|---|
canvas |
the canvas |
selectionHighlight |
the path of the selection highlight or cursor; can be null |
selectionHighlightPaint |
the paint for the selection highlight |
cursorOffsetVertical |
the amount to temporarily translate the canvas while rendering the highlight |
ellipsized
open fun ellipsized(
start: Int,
end: Int
): Unit
Callback for the ellipsizer to report what region it ellipsized.
getEllipsizedWidth
open fun getEllipsizedWidth(): Int
Return | |
---|---|
Int |
the amount of ellipsized width in pixels. Value is 0 or greater |
isBoring
open static fun isBoring(
text: CharSequence!,
paint: TextPaint!
): BoringLayout.Metrics!
Determine and compute metrics if given text can be handled by BoringLayout.
Parameters | |
---|---|
text |
CharSequence!: a text |
paint |
TextPaint!: a paint |
Return | |
---|---|
BoringLayout.Metrics! |
layout metric for the given text. null if given text is unable to be handled by BoringLayout. |
isBoring
open static fun isBoring(
text: CharSequence!,
paint: TextPaint!,
metrics: BoringLayout.Metrics!
): BoringLayout.Metrics!
Determine and compute metrics if given text can be handled by BoringLayout.
Parameters | |
---|---|
text |
CharSequence!: a text |
paint |
TextPaint!: a paint |
metrics |
BoringLayout.Metrics!: a metrics object to be recycled. If null is passed, this function creat new object. |
Return | |
---|---|
BoringLayout.Metrics! |
layout metric for the given text. If metrics is not null, this method fills values to given metrics object instead of allocating new metrics object. null if given text is unable to be handled by BoringLayout. |
isBoring
open static fun isBoring(
text: CharSequence,
paint: TextPaint,
textDir: TextDirectionHeuristic,
useFallbackLineSpacing: Boolean,
metrics: BoringLayout.Metrics?
): BoringLayout.Metrics?
Returns null if not boring; the width, ascent, and descent in the provided Metrics object (or a new one if the provided one was null) if boring.
Parameters | |
---|---|
text |
CharSequence: a text to be calculated text layout. This value cannot be null . |
paint |
TextPaint: a paint object used for styling. This value cannot be null . |
textDir |
TextDirectionHeuristic: a text direction. This value cannot be null . |
useFallbackLineSpacing |
Boolean: True for adjusting the line spacing based on fallback fonts. False for keeping the first font's line height. If some glyphs requires larger vertical spaces, by passing true to this argument, the layout increase the line height to fit all glyphs. |
metrics |
BoringLayout.Metrics?: the out metrics. This value may be null . |
Return | |
---|---|
BoringLayout.Metrics? |
metrics on success. null if text cannot be rendered by BoringLayout. |
isFallbackLineSpacingEnabled
open fun isFallbackLineSpacingEnabled(): Boolean
Return | |
---|---|
Boolean |
true if the fallback line space is enabled. Otherwise, returns false. |
make
open static fun make(
source: CharSequence!,
paint: TextPaint!,
outerWidth: Int,
align: Layout.Alignment!,
spacingMult: Float,
spacingAdd: Float,
metrics: BoringLayout.Metrics!,
includePad: Boolean
): BoringLayout!
Utility function to construct a BoringLayout instance.
Parameters | |
---|---|
source |
CharSequence!: the text to render |
paint |
TextPaint!: the default paint for the layout |
outerWidth |
Int: the wrapping width for the text |
align |
Layout.Alignment!: whether to left, right, or center the text |
spacingMult |
Float: this value is no longer used by BoringLayout |
spacingAdd |
Float: this value is no longer used by BoringLayout |
metrics |
BoringLayout.Metrics!: Metrics instance that contains information about FontMetrics and line width |
includePad |
Boolean: set whether to include extra space beyond font ascent and descent which is needed to avoid clipping in some scripts |
make
open static fun make(
source: CharSequence!,
paint: TextPaint!,
outerWidth: Int,
align: Layout.Alignment!,
spacingmult: Float,
spacingadd: Float,
metrics: BoringLayout.Metrics!,
includePad: Boolean,
ellipsize: TextUtils.TruncateAt!,
ellipsizedWidth: Int
): BoringLayout!
Utility function to construct a BoringLayout instance.
Parameters | |
---|---|
source |
CharSequence!: the text to render |
paint |
TextPaint!: the default paint for the layout |
outerWidth |
Int: the wrapping width for the text |
align |
Layout.Alignment!: whether to left, right, or center the text |
spacingmult |
Float: this value is no longer used by BoringLayout |
spacingadd |
Float: this value is no longer used by BoringLayout |
metrics |
BoringLayout.Metrics!: Metrics instance that contains information about FontMetrics and line width |
includePad |
Boolean: set whether to include extra space beyond font ascent and descent which is needed to avoid clipping in some scripts |
ellipsize |
TextUtils.TruncateAt!: whether to ellipsize the text if width of the text is longer than the requested width |
ellipsizedWidth |
Int: the width to which this Layout is ellipsizing. If ellipsize is null , or is TextUtils.TruncateAt#MARQUEE this value is not used, outerWidth is used instead |
make
open static fun make(
source: CharSequence,
paint: TextPaint,
outerWidth: Int,
align: Layout.Alignment,
metrics: BoringLayout.Metrics,
includePad: Boolean,
ellipsize: TextUtils.TruncateAt?,
ellipsizedWidth: Int,
useFallbackLineSpacing: Boolean
): BoringLayout
Utility function to construct a BoringLayout instance. The spacing multiplier and additional amount spacing are not used by BoringLayout. Layout#getSpacingMultiplier()
will return 1.0 and Layout#getSpacingAdd()
will return 0.0.
Parameters | |
---|---|
source |
CharSequence: the text to render This value cannot be null . |
paint |
TextPaint: the default paint for the layout This value cannot be null . |
outerWidth |
Int: the wrapping width for the text Value is 0 or greater |
align |
Layout.Alignment: whether to left, right, or center the text This value cannot be null . |
metrics |
BoringLayout.Metrics: Metrics instance that contains information about FontMetrics and line width This value cannot be null . |
includePad |
Boolean: set whether to include extra space beyond font ascent and descent which is needed to avoid clipping in some scripts |
ellipsize |
TextUtils.TruncateAt?: whether to ellipsize the text if width of the text is longer than the requested width. null if ellipsis is not applied. |
ellipsizedWidth |
Int: the width to which this Layout is ellipsizing. If ellipsize is null , or is TextUtils.TruncateAt#MARQUEE this value is not used, outerWidth is used instead Value is 0 or greater |
useFallbackLineSpacing |
Boolean: True for adjusting the line spacing based on fallback fonts. False for keeping the first font's line height. If some glyphs requires larger vertical spaces, by passing true to this argument, the layout increase the line height to fit all glyphs. |
Return | |
---|---|
BoringLayout |
This value cannot be null . |
replaceOrMake
open fun replaceOrMake(
source: CharSequence!,
paint: TextPaint!,
outerwidth: Int,
align: Layout.Alignment!,
spacingMult: Float,
spacingAdd: Float,
metrics: BoringLayout.Metrics!,
includePad: Boolean
): BoringLayout!
Returns a BoringLayout for the specified text, potentially reusing this one if it is already suitable. The caller must make sure that no one is still using this Layout.
Parameters | |
---|---|
source |
CharSequence!: the text to render |
paint |
TextPaint!: the default paint for the layout |
outerwidth |
Int: the wrapping width for the text |
align |
Layout.Alignment!: whether to left, right, or center the text |
spacingMult |
Float: this value is no longer used by BoringLayout |
spacingAdd |
Float: this value is no longer used by BoringLayout |
metrics |
BoringLayout.Metrics!: Metrics instance that contains information about FontMetrics and line width |
includePad |
Boolean: set whether to include extra space beyond font ascent and descent which is needed to avoid clipping in some scripts |
replaceOrMake
open fun replaceOrMake(
source: CharSequence,
paint: TextPaint,
outerWidth: Int,
align: Layout.Alignment,
metrics: BoringLayout.Metrics,
includePad: Boolean,
ellipsize: TextUtils.TruncateAt?,
ellipsizedWidth: Int,
useFallbackLineSpacing: Boolean
): BoringLayout
Returns a BoringLayout for the specified text, potentially reusing this one if it is already suitable. The caller must make sure that no one is still using this Layout. The spacing multiplier and additional amount spacing are not used by BoringLayout. Layout#getSpacingMultiplier()
will return 1.0 and Layout#getSpacingAdd()
will return 0.0.
Parameters | |
---|---|
source |
CharSequence: the text to render This value cannot be null . |
paint |
TextPaint: the default paint for the layout This value cannot be null . |
outerWidth |
Int: the wrapping width for the text Value is 0 or greater |
align |
Layout.Alignment: whether to left, right, or center the text This value cannot be null . |
metrics |
BoringLayout.Metrics: Metrics instance that contains information about FontMetrics and line width This value cannot be null . |
includePad |
Boolean: set whether to include extra space beyond font ascent and descent which is needed to avoid clipping in some scripts |
ellipsize |
TextUtils.TruncateAt?: whether to ellipsize the text if width of the text is longer than the requested width. null if ellipsis not applied. |
ellipsizedWidth |
Int: the width to which this Layout is ellipsizing. If ellipsize is null , or is TextUtils.TruncateAt#MARQUEE this value is not used, outerWidth is used instead Value is 0 or greater |
useFallbackLineSpacing |
Boolean: True for adjusting the line spacing based on fallback fonts. False for keeping the first font's line height. If some glyphs requires larger vertical spaces, by passing true to this argument, the layout increase the line height to fit all glyphs. |
Return | |
---|---|
BoringLayout |
This value cannot be null . |
replaceOrMake
open fun replaceOrMake(
source: CharSequence!,
paint: TextPaint!,
outerWidth: Int,
align: Layout.Alignment!,
spacingMult: Float,
spacingAdd: Float,
metrics: BoringLayout.Metrics!,
includePad: Boolean,
ellipsize: TextUtils.TruncateAt!,
ellipsizedWidth: Int
): BoringLayout!
Returns a BoringLayout for the specified text, potentially reusing this one if it is already suitable. The caller must make sure that no one is still using this Layout.
Parameters | |
---|---|
source |
CharSequence!: the text to render |
paint |
TextPaint!: the default paint for the layout |
outerWidth |
Int: the wrapping width for the text |
align |
Layout.Alignment!: whether to left, right, or center the text |
spacingMult |
Float: this value is no longer used by BoringLayout |
spacingAdd |
Float: this value is no longer used by BoringLayout |
metrics |
BoringLayout.Metrics!: Metrics instance that contains information about FontMetrics and line width |
includePad |
Boolean: set whether to include extra space beyond font ascent and descent which is needed to avoid clipping in some scripts |
ellipsize |
TextUtils.TruncateAt!: whether to ellipsize the text if width of the text is longer than the requested width |
ellipsizedWidth |
Int: the width to which this Layout is ellipsizing. If ellipsize is null , or is TextUtils.TruncateAt#MARQUEE this value is not used, outerWidth is used instead |