public class BoringLayout extends Layout implements TextUtils.EllipsizeCallback
isBoring(java.lang.CharSequence, android.text.TextPaint)
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.
Modifier and Type | Class and Description |
---|---|
static class |
BoringLayout.Metrics |
Layout.Alignment, Layout.Directions
DIR_LEFT_TO_RIGHT, DIR_RIGHT_TO_LEFT
Constructor and Description |
---|
BoringLayout(CharSequence source,
TextPaint paint,
int outerwidth,
Layout.Alignment align,
float spacingmult,
float spacingadd,
BoringLayout.Metrics metrics,
boolean includepad) |
BoringLayout(CharSequence source,
TextPaint paint,
int outerwidth,
Layout.Alignment align,
float spacingmult,
float spacingadd,
BoringLayout.Metrics metrics,
boolean includepad,
TextUtils.TruncateAt ellipsize,
int ellipsizedWidth) |
Modifier and Type | Method and Description |
---|---|
void |
draw(Canvas c,
Path highlight,
Paint highlightpaint,
int cursorOffset)
Draw this Layout on the specified canvas, with the highlight path drawn
between the background and the text.
|
void |
ellipsized(int start,
int end)
Callback for the ellipsizer to report what region it ellipsized.
|
int |
getBottomPadding()
Returns the number of extra pixels of descent padding in the
bottom line of the Layout.
|
int |
getEllipsisCount(int line)
Returns the number of characters to be ellipsized away, or 0 if
no ellipsis is to take place.
|
int |
getEllipsisStart(int line)
Return the offset of the first character to be ellipsized away,
relative to the start of the line.
|
int |
getEllipsizedWidth()
Return the width to which this Layout is ellipsizing, or
Layout.getWidth() if it is not doing anything special. |
int |
getHeight()
Return the total height of this layout.
|
boolean |
getLineContainsTab(int line)
Returns whether the specified line contains one or more
characters that need to be handled specially, like tabs
or emoji.
|
int |
getLineCount()
Return the number of lines of text in this layout.
|
int |
getLineDescent(int line)
Return the descent of the specified line(0…getLineCount() - 1).
|
Layout.Directions |
getLineDirections(int line)
Returns the directional run information for the specified line.
|
float |
getLineMax(int line)
Gets the unsigned horizontal extent of the specified line, including
leading margin indent, but excluding trailing whitespace.
|
int |
getLineStart(int line)
Return the text offset of the beginning of the specified line (
0…getLineCount()).
|
int |
getLineTop(int line)
Return the vertical position of the top of the specified line
(0…getLineCount()).
|
int |
getParagraphDirection(int line)
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
Layout.DIR_LEFT_TO_RIGHT , Layout.DIR_RIGHT_TO_LEFT ). |
int |
getTopPadding()
Returns the (negative) number of extra pixels of ascent padding in the
top line of the Layout.
|
static BoringLayout.Metrics |
isBoring(CharSequence text,
TextPaint paint)
Returns null if not boring; the width, ascent, and descent if boring.
|
static BoringLayout.Metrics |
isBoring(CharSequence text,
TextPaint paint,
BoringLayout.Metrics 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.
|
static BoringLayout.Metrics |
isBoring(CharSequence text,
TextPaint paint,
TextDirectionHeuristic textDir)
Returns null if not boring; the width, ascent, and descent if boring.
|
static BoringLayout.Metrics |
isBoring(CharSequence text,
TextPaint paint,
TextDirectionHeuristic textDir,
BoringLayout.Metrics 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.
|
static BoringLayout |
make(CharSequence source,
TextPaint paint,
int outerwidth,
Layout.Alignment align,
float spacingmult,
float spacingadd,
BoringLayout.Metrics metrics,
boolean includepad) |
static BoringLayout |
make(CharSequence source,
TextPaint paint,
int outerwidth,
Layout.Alignment align,
float spacingmult,
float spacingadd,
BoringLayout.Metrics metrics,
boolean includepad,
TextUtils.TruncateAt ellipsize,
int ellipsizedWidth) |
BoringLayout |
replaceOrMake(CharSequence source,
TextPaint paint,
int outerwidth,
Layout.Alignment align,
float spacingmult,
float spacingadd,
BoringLayout.Metrics metrics,
boolean includepad)
Returns a BoringLayout for the specified text, potentially reusing
this one if it is already suitable.
|
BoringLayout |
replaceOrMake(CharSequence source,
TextPaint paint,
int outerwidth,
Layout.Alignment align,
float spacingmult,
float spacingadd,
BoringLayout.Metrics metrics,
boolean includepad,
TextUtils.TruncateAt ellipsize,
int ellipsizedWidth)
Returns a BoringLayout for the specified text, potentially reusing
this one if it is already suitable.
|
draw, drawBackground, drawText, getAlignment, getCursorPath, getDesiredWidth, getDesiredWidth, getLineAscent, getLineBaseline, getLineBottom, getLineBounds, getLineEnd, getLineForOffset, getLineForVertical, getLineLeft, getLineRangeForDraw, getLineRight, getLineVisibleEnd, getLineWidth, getOffsetForHorizontal, getOffsetToLeftOf, getOffsetToRightOf, getPaint, getParagraphAlignment, getParagraphLeft, getParagraphRight, getPrimaryHorizontal, getSecondaryHorizontal, getSelectionPath, getSpacingAdd, getSpacingMultiplier, getText, getTextDirectionHeuristic, getWidth, increaseWidthTo, isLevelBoundary, isRtlCharAt, isSpanned
public BoringLayout(CharSequence source, TextPaint paint, int outerwidth, Layout.Alignment align, float spacingmult, float spacingadd, BoringLayout.Metrics metrics, boolean includepad)
public BoringLayout(CharSequence source, TextPaint paint, int outerwidth, Layout.Alignment align, float spacingmult, float spacingadd, BoringLayout.Metrics metrics, boolean includepad, TextUtils.TruncateAt ellipsize, int ellipsizedWidth)
public static BoringLayout make(CharSequence source, TextPaint paint, int outerwidth, Layout.Alignment align, float spacingmult, float spacingadd, BoringLayout.Metrics metrics, boolean includepad)
public static BoringLayout make(CharSequence source, TextPaint paint, int outerwidth, Layout.Alignment align, float spacingmult, float spacingadd, BoringLayout.Metrics metrics, boolean includepad, TextUtils.TruncateAt ellipsize, int ellipsizedWidth)
public BoringLayout replaceOrMake(CharSequence source, TextPaint paint, int outerwidth, Layout.Alignment align, float spacingmult, float spacingadd, BoringLayout.Metrics metrics, boolean includepad)
public BoringLayout replaceOrMake(CharSequence source, TextPaint paint, int outerwidth, Layout.Alignment align, float spacingmult, float spacingadd, BoringLayout.Metrics metrics, boolean includepad, TextUtils.TruncateAt ellipsize, int ellipsizedWidth)
public static BoringLayout.Metrics isBoring(CharSequence text, TextPaint paint)
public static BoringLayout.Metrics isBoring(CharSequence text, TextPaint paint, TextDirectionHeuristic textDir)
public static BoringLayout.Metrics isBoring(CharSequence text, TextPaint paint, BoringLayout.Metrics metrics)
public static BoringLayout.Metrics isBoring(CharSequence text, TextPaint paint, TextDirectionHeuristic textDir, BoringLayout.Metrics metrics)
public int getHeight()
Layout
public int getLineCount()
Layout
getLineCount
in class Layout
public int getLineTop(int line)
Layout
getLineTop
in class Layout
public int getLineDescent(int line)
Layout
getLineDescent
in class Layout
public int getLineStart(int line)
Layout
getLineStart
in class Layout
public int getParagraphDirection(int line)
Layout
Layout.DIR_LEFT_TO_RIGHT
, Layout.DIR_RIGHT_TO_LEFT
).getParagraphDirection
in class Layout
public boolean getLineContainsTab(int line)
Layout
getLineContainsTab
in class Layout
public float getLineMax(int line)
Layout
getLineMax
in class Layout
public final Layout.Directions getLineDirections(int line)
Layout
NOTE: this is inadequate to support bidirectional text, and will change.
getLineDirections
in class Layout
public int getTopPadding()
Layout
getTopPadding
in class Layout
public int getBottomPadding()
Layout
getBottomPadding
in class Layout
public int getEllipsisCount(int line)
Layout
getEllipsisCount
in class Layout
public int getEllipsisStart(int line)
Layout
getEllipsisStart
in class Layout
public int getEllipsizedWidth()
Layout
Layout.getWidth()
if it is not doing anything special.getEllipsizedWidth
in class Layout
public void draw(Canvas c, Path highlight, Paint highlightpaint, int cursorOffset)
Layout
public void ellipsized(int start, int end)
ellipsized
in interface TextUtils.EllipsizeCallback