BoringLayout
open class BoringLayout : Layout, TextUtils.EllipsizeCallback
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
Inherited constants |
From class Layout
Int |
BREAK_STRATEGY_BALANCED
Value for break strategy indicating balanced line breaking. The breaks are chosen to make all lines as close to the same length as possible, including automatic hyphenation.
|
Int |
BREAK_STRATEGY_HIGH_QUALITY
Value for break strategy indicating high quality line breaking, including automatic hyphenation and doing whole-paragraph optimization of line breaks.
|
Int |
BREAK_STRATEGY_SIMPLE
Value for break strategy indicating simple line breaking. Automatic hyphens are not added (though soft hyphens are respected), and modifying text generally doesn't affect the layout before it (which yields a more consistent user experience when editing), but layout may not be the highest quality.
|
Float |
DEFAULT_LINESPACING_ADDITION
|
Float |
DEFAULT_LINESPACING_MULTIPLIER
|
Int |
DIR_LEFT_TO_RIGHT
|
Int |
DIR_RIGHT_TO_LEFT
|
Int |
HYPHENATION_FREQUENCY_FULL
Value for hyphenation frequency indicating the full amount of automatic hyphenation, typical in typography. Useful for running text and where it's important to put the maximum amount of text in a screen with limited space.
|
Int |
HYPHENATION_FREQUENCY_FULL_FAST
Value for hyphenation frequency indicating the full amount of automatic hyphenation with using faster algorithm. This option is useful for running text and where it's important to put the maximum amount of text in a screen with limited space. To make text rendering faster with hyphenation, this algorithm ignores some hyphen character related typographic features, e.g. kerning.
|
Int |
HYPHENATION_FREQUENCY_NONE
Value for hyphenation frequency indicating no automatic hyphenation. Useful for backward compatibility, and for cases where the automatic hyphenation algorithm results in incorrect hyphenation. Mid-word breaks may still happen when a word is wider than the layout and there is otherwise no valid break. Soft hyphens are ignored and will not be used as suggestions for potential line breaks.
|
Int |
HYPHENATION_FREQUENCY_NORMAL
Value for hyphenation frequency indicating a light amount of automatic hyphenation, which is a conservative default. Useful for informal cases, such as short sentences or chat messages.
|
Int |
HYPHENATION_FREQUENCY_NORMAL_FAST
Value for hyphenation frequency indicating a light amount of automatic hyphenation with using faster algorithm. This option is useful for informal cases, such as short sentences or chat messages. To make text rendering faster with hyphenation, this algorithm ignores some hyphen character related typographic features, e.g. kerning.
|
Int |
JUSTIFICATION_MODE_INTER_CHARACTER
Value for justification mode indicating the text is justified by stretching letter spacing.
|
Int |
JUSTIFICATION_MODE_INTER_WORD
Value for justification mode indicating the text is justified by stretching word spacing.
|
Int |
JUSTIFICATION_MODE_NONE
Value for justification mode indicating no justification.
|
|
Public constructors |
|
|
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 |
Callback for the ellipsizer to report what region it ellipsized.
|
open Int |
|
open Int |
|
open Int |
|
open Int |
|
open Int |
|
open Boolean |
|
open Int |
|
open Int |
|
Layout.Directions! |
|
open Float |
|
open Int |
|
open Int |
|
open Float |
|
open Int |
|
open Int |
|
open static BoringLayout.Metrics! |
Determine and compute metrics if given text can be handled by BoringLayout.
|
open static BoringLayout.Metrics! |
Determine and compute metrics if given text can be handled by BoringLayout.
|
open static 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! |
Utility function to construct a BoringLayout instance.
|
open static BoringLayout! |
Utility function to construct a BoringLayout instance.
|
open static BoringLayout |
Utility function to construct a BoringLayout instance.
|
open BoringLayout! |
Returns a BoringLayout for the specified text, potentially reusing this one if it is already suitable.
|
open BoringLayout |
Returns a BoringLayout for the specified text, potentially reusing this one if it is already suitable.
|
open BoringLayout! |
Returns a BoringLayout for the specified text, potentially reusing this one if it is already suitable.
|
Inherited functions |
From class Layout
Unit |
draw(c: Canvas!)
Draw this Layout on the specified Canvas. This API draws background first, then draws text on top of it.
|
Unit |
draw(canvas: Canvas, highlightPaths: MutableList<Path!>?, highlightPaints: MutableList<Paint!>?, selectionPath: Path?, selectionPaint: Paint?, cursorOffsetVertical: Int)
Draw this layout on the specified canvas. This API draws background first, then draws highlight paths on top of it, then draws selection or cursor, then finally draws text on top of it.
|
Unit |
drawBackground(canvas: Canvas)
Draw background of this layout. Different from draw(android.graphics.Canvas,java.util.List,java.util.List,android.graphics.Path,android.graphics.Paint,int) API, this API only draws background, not drawing text, highlights or selections. The background here is drawn by LineBackgroundSpan attached to the text.
|
Unit |
drawText(canvas: Canvas)
Draw text part of this layout. Different from draw(android.graphics.Canvas,java.util.List,java.util.List,android.graphics.Path,android.graphics.Paint,int) API, this API only draws text part, not drawing highlights, selections, or backgrounds.
|
Unit |
fillCharacterBounds(start: Int, end: Int, bounds: FloatArray, boundsStart: Int)
Return the characters' bounds in the given range. The bounds array will be filled starting from boundsStart (inclusive). The coordinates are in local text layout.
|
Layout.Alignment |
getAlignment()
Returns the alignment used for creating this layout in pixels.
|
Int |
getBreakStrategy()
Return the break strategy used for creating this layout.
|
Unit |
getCursorPath(point: Int, dest: Path!, editingBuffer: CharSequence!)
Fills in the specified Path with a representation of a cursor at the specified offset. This will often be a vertical line but can be multiple discontinuous lines in text with multiple directionalities.
|
Float |
getDesiredWidth(source: CharSequence!, paint: TextPaint!)
Return how wide a layout must be in order to display the specified text with one line per paragraph.
As of O, Uses TextDirectionHeuristics#FIRSTSTRONG_LTR as the default text direction heuristics. In the earlier versions uses TextDirectionHeuristics#LTR as the default.
|
Float |
getDesiredWidth(source: CharSequence!, start: Int, end: Int, paint: TextPaint!)
Return how wide a layout must be in order to display the specified text slice with one line per paragraph.
As of O, Uses TextDirectionHeuristics#FIRSTSTRONG_LTR as the default text direction heuristics. In the earlier versions uses TextDirectionHeuristics#LTR as the default.
|
TextUtils.TruncateAt? |
getEllipsize()
Return the ellipsize option used for creating this layout. May return null if no ellipsize option was selected.
|
Int |
getHyphenationFrequency()
Return the hyphenation frequency used for creating this layout.
|
Int |
getJustificationMode()
Return the justification mode used for creating this layout.
|
IntArray? |
getLeftIndents()
Return a copy of the left indents used for this layout. May return null if no left indentation is applied.
|
Int |
getLineAscent(line: Int)
Get the ascent of the text on the specified line. The return value is negative to match the Paint.ascent() convention.
|
Int |
getLineBaseline(line: Int)
Return the vertical position of the baseline of the specified line.
|
Int |
getLineBottom(line: Int)
Return the vertical position of the bottom of the specified line.
|
Int |
getLineBottom(line: Int, includeLineSpacing: Boolean)
Return the vertical position of the bottom of the specified line.
|
Int |
getLineBounds(line: Int, bounds: Rect!)
Return the baseline for the specified line (0…getLineCount() - 1) If bounds is not null, return the top, left, right, bottom extents of the specified line in it.
|
LineBreakConfig |
getLineBreakConfig()
Gets the LineBreakConfig used for creating this layout. Do not modify the returned object.
|
Int |
getLineEnd(line: Int)
Return the text offset after the last character on the specified line.
|
Int |
getLineForOffset(offset: Int)
Get the line number on which the specified text offset appears. If you ask for a position before 0, you get 0; if you ask for a position beyond the end of the text, you get the last line.
|
Int |
getLineForVertical(vertical: Int)
Get the line number corresponding to the specified vertical position. If you ask for a position above 0, you get 0; if you ask for a position below the bottom of the text, you get the last line.
|
Float |
getLineLeft(line: Int)
Get the leftmost position that should be exposed for horizontal scrolling on the specified line.
|
Int |
getLineLetterSpacingUnitCount(line: Int, includeTrailingWhitespace: Boolean)
Returns the number of letter spacing unit in the line.
This API returns a number of letters that is a target of letter spacing. The letter spacing won't be added to the middle of the characters that are needed to be treated as a single, e.g., ligatured or conjunct form. Note that this value is different from the number of] grapheme clusters that is calculated by BreakIterator#getCharacterInstance(Locale) . For example, if the "fi" is ligatured, the ligatured form is treated as single uni and letter spacing is not added, but it has two separate grapheme cluster.
This value is used for calculating the letter spacing amount for the justification because the letter spacing is applied between clusters. For example, if extra W pixels needed to be filled by letter spacing, the amount of letter spacing to be applied is W /(letter spacing unit count - 1) px.
|
Float |
getLineRight(line: Int)
Get the rightmost position that should be exposed for horizontal scrolling on the specified line.
|
Float |
getLineSpacingAmount()
Returns the amount added to the line height.
|
Float |
getLineSpacingMultiplier()
Returns the multiplier applied to the line height.
|
Int |
getLineVisibleEnd(line: Int)
Return the text offset after the last visible character (so whitespace is not counted) on the specified line.
|
Int |
getMaxLines()
Return the maximum lines allowed used for creating this layout. Note that this is not an actual line count of this layout. Use getLineCount() for getting the actual line count of this layout.
|
Paint.FontMetrics? |
getMinimumFontMetrics()
Get the minimum font metrics used for line spacing.
|
Int |
getOffsetForHorizontal(line: Int, horiz: Float)
Get the character offset on the specified line whose position is closest to the specified horizontal position.
|
Int |
getOffsetToLeftOf(offset: Int)
|
Int |
getOffsetToRightOf(offset: Int)
|
TextPaint |
getPaint()
Return the paint used for creating this layout. Do not modify the returned paint object. This paint object will still be used for drawing/measuring text.
|
Layout.Alignment! |
getParagraphAlignment(line: Int)
Get the alignment of the specified paragraph, taking into account markup attached to it.
|
Int |
getParagraphLeft(line: Int)
Get the left edge of the specified paragraph, inset by left margins.
|
Int |
getParagraphRight(line: Int)
Get the right edge of the specified paragraph, inset by right margins.
|
Float |
getPrimaryHorizontal(offset: Int)
Get the primary horizontal position for the specified text offset. This is the location where a new character would be inserted in the paragraph's primary direction.
|
IntArray? |
getRangeForRect(area: RectF, segmentFinder: SegmentFinder, inclusionStrategy: Layout.TextInclusionStrategy)
Finds the range of text which is inside the specified rectangle area. The start of the range is the start of the first text segment inside the area, and the end of the range is the end of the last text segment inside the area.
A text segment is considered to be inside the area according to the provided TextInclusionStrategy . If a text segment spans multiple lines or multiple directional runs (e.g. a hyphenated word), the text segment is divided into pieces at the line and run breaks, then the text segment is considered to be inside the area if any of its pieces are inside the area.
The returned range may also include text segments which are not inside the specified area, if those text segments are in between text segments which are inside the area. For example, the returned range may be "segment1 segment2 segment3" if "segment1" and "segment3" are inside the area and "segment2" is not.
|
IntArray? |
getRightIndents()
Return a copy of the right indents used for this layout. May return null if no right indentation is applied.
|
Float |
getSecondaryHorizontal(offset: Int)
Get the secondary horizontal position for the specified text offset. This is the location where a new character would be inserted in the direction other than the paragraph's primary direction.
|
Unit |
getSelectionPath(start: Int, end: Int, dest: Path!)
Fills in the specified Path with a representation of a highlight between the specified offsets. This will often be a rectangle or a potentially discontinuous set of rectangles. If the start and end are the same, the returned path is empty.
|
Boolean |
getShiftDrawingOffsetForStartOverhang()
Returns true if shifting drawing offset for start overhang.
|
Float |
getSpacingAdd()
Returns the amount added to the line height.
|
Float |
getSpacingMultiplier()
Returns the multiplier applied to the line height.
|
CharSequence |
getText()
Return the text used for creating this layout.
|
TextDirectionHeuristic |
getTextDirectionHeuristic()
Returns the text direction heuristic used for creating this layout.
|
Boolean |
getUseBoundsForWidth()
Returns true if using bounding box as a width, false for using advance as a width.
|
Int |
getWidth()
Return the width used for creating this layout in pixels.
|
Unit |
increaseWidthTo(wid: Int)
Increase the width of this layout to the specified width. Be careful to use this only when you know it is appropriate— it does not cause the text to reflow to use the full new width.
|
Boolean |
isFontPaddingIncluded()
Returns true if this layout is created with increased line height.
|
Boolean |
isRtlCharAt(offset: Int)
Returns true if the character at offset is right to left (RTL).
|
Boolean |
isSpanned()
|
|
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.
getBottomPadding
open fun getBottomPadding(): Int
getEllipsisCount
open fun getEllipsisCount(line: Int): Int
getEllipsisStart
open fun getEllipsisStart(line: Int): Int
getEllipsizedWidth
open fun getEllipsizedWidth(): Int
Return |
Int |
the amount of ellipsized width in pixels. Value is 0 or greater |
getHeight
open fun getHeight(): Int
getLineContainsTab
open fun getLineContainsTab(line: Int): Boolean
getLineCount
open fun getLineCount(): Int
getLineDescent
open fun getLineDescent(line: Int): Int
getLineMax
open fun getLineMax(line: Int): Float
getLineStart
open fun getLineStart(line: Int): Int
getLineTop
open fun getLineTop(line: Int): Int
getLineWidth
open fun getLineWidth(line: Int): Float
getParagraphDirection
open fun getParagraphDirection(line: Int): Int
getTopPadding
open fun getTopPadding(): Int
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.
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 . |
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. |
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. |
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 |