EmphasisSpan
public final class EmphasisSpan extends ReplacementSpan
| java.lang.Object | ||||
| ↳ | android.text.style.CharacterStyle | |||
| ↳ | android.text.style.MetricAffectingSpan | |||
| ↳ | android.text.style.ReplacementSpan | |||
| ↳ | androidx.text.vertical.EmphasisSpan |
A span that applies emphasis marks to text in a vertical layout.
This span is designed for use with VerticalTextLayout and will not have an effect in other contexts. It allows for the application of various emphasis styles, such as dots, circles, or triangles, above or next to characters in vertical text.
The EmphasisSpan takes a style, a boolean indicating whether the mark should be filled, and a scale factor for the size of the mark.
Summary
Constants |
|
|---|---|
static final boolean |
DEFAULT_EMPHASIS_FILL = trueThe default value for whether the emphasis mark should be filled. |
static final float |
DEFAULT_SCALE = 0.5fThe default scale factor for emphasis marks. |
Public fields |
|
|---|---|
static final @NonNull EmphasisStyle |
The default style used for emphasis marks, typically a dot. |
static final @NonNull AnnotationPosition |
The default position of the emphasis mark relative to the text. |
Public constructors |
|---|
EmphasisSpan( |
Public methods |
|
|---|---|
void |
|
final @NonNull AnnotationPosition |
The position of the emphasis mark relative to the text. |
final float |
getScale()The scale factor for the size of the mark. |
int |
getSize( |
final @NonNull EmphasisStyle |
getStyle()The style of the emphasis mark. |
final boolean |
isFilled()Whether the mark should be filled or outlined. |
Inherited methods |
||||||||
|---|---|---|---|---|---|---|---|---|
|
Constants
DEFAULT_EMPHASIS_FILL
public static final boolean DEFAULT_EMPHASIS_FILL = true
The default value for whether the emphasis mark should be filled.
DEFAULT_SCALE
public static final float DEFAULT_SCALE = 0.5f
The default scale factor for emphasis marks.
Public fields
DEFAULT_EMPHASIS_STYLE
public static final @NonNull EmphasisStyle DEFAULT_EMPHASIS_STYLE
The default style used for emphasis marks, typically a dot.
DEFAULT_POSITION
public static final @NonNull AnnotationPosition DEFAULT_POSITION
The default position of the emphasis mark relative to the text.
Public constructors
EmphasisSpan
public EmphasisSpan(
@NonNull EmphasisStyle style,
boolean isFilled,
@NonNull AnnotationPosition position,
float scale
)
| Parameters | |
|---|---|
@NonNull EmphasisStyle style |
The style of the emphasis mark. |
boolean isFilled |
Whether the mark should be filled or outlined. When |
@NonNull AnnotationPosition position |
The position of the emphasis mark relative to the text. NOTE: this is reserved value, to be implemented (b/495457561). |
float scale |
The scale factor for the size of the mark. This value determines the size of the emphasis mark relative to the font size. A scale of 0.5f means the emphasis mark will be half the size of the text. |
Public methods
draw
public void draw(
@NonNull Canvas canvas,
CharSequence text,
int start,
int end,
float x,
int top,
int y,
int bottom,
@NonNull Paint paint
)
getPosition
public final @NonNull AnnotationPosition getPosition()
The position of the emphasis mark relative to the text. NOTE: this is reserved value, to be implemented (b/495457561).
getScale
public final float getScale()
The scale factor for the size of the mark. This value determines the size of the emphasis mark relative to the font size. A scale of 0.5f means the emphasis mark will be half the size of the text.
getSize
public int getSize(
@NonNull Paint paint,
CharSequence text,
int start,
int end,
Paint.FontMetricsInt fm
)
getStyle
public final @NonNull EmphasisStyle getStyle()
The style of the emphasis mark.
isFilled
public final boolean isFilled()
Whether the mark should be filled or outlined. When true, the emphasis mark will be drawn as a solid shape. When false, it will be drawn as an outline.