CurvedTextView
public class CurvedTextView extends View implements ArcLayout.Widget
CurvedTextView is a component allowing developers to easily write curved text following the curvature of the largest circle that can be inscribed in the view. ArcLayout could be used to concatenate multiple curved texts, also layout together with other widgets such as icons.
Summary
Public constructors |
|---|
CurvedTextView(@NonNull Context context) |
CurvedTextView(@NonNull Context context, @Nullable AttributeSet attrs) |
CurvedTextView( |
CurvedTextView( |
Public methods |
|
|---|---|
void |
|
void |
|
@FloatRange(from = 0.0, to = 360.0, toInclusive = true) float |
Returns the anchor angle used for positioning the text, in degrees. |
int |
Returns the anchor type for positioning the curved text |
@Nullable TextUtils.TruncateAt |
Returns where, if anywhere, words that are longer than the view is wide should be ellipsized. |
@Nullable String |
Returns the font feature settings. |
@Nullable String |
Returns TrueType or OpenType font variation settings. |
float |
Gets the text letter-space value, which determines the spacing between characters. |
@FloatRange(from = 0.0, to = 360.0, toInclusive = true) float |
Returns the maximum sweep angle in degrees for rendering the text |
@FloatRange(from = 0.0, to = 360.0, toInclusive = true) float |
Returns the sweep angle in degrees for rendering the text |
@FloatRange(from = 0.0, to = 360.0, toInclusive = true) float |
Returns the sweep angle that this widget is drawn with. |
@Nullable String |
getText()Returns the text to be rendered |
@ColorInt int |
Returns the color for rendering the text |
float |
Returns the text size for rendering the text |
@Px int |
Returns the thickness of this widget inside the arc. |
@Nullable Typeface |
Gets the current Typeface that is used to style the text. |
boolean |
Returns the curved text layout direction |
boolean |
isPointInsideClickArea(float x, float y) |
void |
|
void |
|
boolean |
onTouchEvent(@NonNull MotionEvent event) |
void |
setAnchorAngleDegrees(Sets the anchor angle used for positioning the text, in degrees. |
void |
setAnchorType(int value)Sets the anchor type for positioning the curved text. |
void |
setClockwise(boolean value)Sets the curved text layout direction |
void |
setEllipsize(@Nullable TextUtils.TruncateAt value)Causes words in the text that are longer than the view's width to be ellipsized. |
void |
setFontFeatureSettings(@Nullable String value)Sets font feature settings. |
void |
setFontVariationSettings(@Nullable String value)Sets TrueType or OpenType font variation settings. |
void |
setLetterSpacing(float value)Sets text letter-spacing in ems. |
void |
setSweepAngleDegrees(Set the sweep angle that this widget is drawn with. |
void |
setSweepRangeDegrees(Sets the minimum and maximum sweep angle in degrees for rendering the text. |
void |
Sets the text to be rendered |
void |
setTextColor(@ColorInt int value)Sets the color for rendering the text |
void |
setTextSize(float value)Sets the text size for rendering the text |
void |
setTypeface(@Nullable Typeface value)Sets the typeface and style in which the text should be displayed. |
void |
setTypeface(@Nullable Typeface tf, int style)Sets the typeface and style in which the text should be displayed, and turns on the fake bold and italic bits in the Paint if the Typeface that you provided does not have all the bits in the style that you specified. |
Protected methods |
|
|---|---|
void |
|
void |
onMeasure(int widthMeasureSpec, int heightMeasureSpec) |
void |
onSizeChanged(int w, int h, int oldw, int oldh) |
Inherited Constants |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Inherited methods |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Public constructors
CurvedTextView
public CurvedTextView(@NonNull Context context, @Nullable AttributeSet attrs)
CurvedTextView
public CurvedTextView(
@NonNull Context context,
@Nullable AttributeSet attrs,
int defStyle
)
CurvedTextView
public CurvedTextView(
@NonNull Context context,
@Nullable AttributeSet attrs,
int defStyle,
int defStyleRes
)
Public methods
checkInvalidAttributeAsChild
public void checkInvalidAttributeAsChild()
| Throws | |
|---|---|
java.lang.IllegalArgumentException |
if the anchorType and/or anchorAngleDegrees attributes were set for a widget in ArcLayout |
getAnchorAngleDegrees
public @FloatRange(from = 0.0, to = 360.0, toInclusive = true) float getAnchorAngleDegrees()
Returns the anchor angle used for positioning the text, in degrees.
getAnchorType
public int getAnchorType()
Returns the anchor type for positioning the curved text
getEllipsize
public @Nullable TextUtils.TruncateAt getEllipsize()
Returns where, if anywhere, words that are longer than the view is wide should be ellipsized.
getFontFeatureSettings
public @Nullable String getFontFeatureSettings()
Returns the font feature settings. The format is the same as the CSS font-feature-settings attribute: https://www.w3.org/TR/css-fonts-3/#font-feature-settings-prop
getFontVariationSettings
public @Nullable String getFontVariationSettings()
Returns TrueType or OpenType font variation settings.
getLetterSpacing
public float getLetterSpacing()
Gets the text letter-space value, which determines the spacing between characters. The value returned is in ems. Normally, this value is 0.0.
| Returns | |
|---|---|
float |
The text letter-space value in ems. |
getMaxSweepDegrees
public @FloatRange(from = 0.0, to = 360.0, toInclusive = true) float getMaxSweepDegrees()
Returns the maximum sweep angle in degrees for rendering the text
getMinSweepDegrees
public @FloatRange(from = 0.0, to = 360.0, toInclusive = true) float getMinSweepDegrees()
Returns the sweep angle in degrees for rendering the text
getSweepAngleDegrees
public @FloatRange(from = 0.0, to = 360.0, toInclusive = true) float getSweepAngleDegrees()
Returns the sweep angle that this widget is drawn with.
getTextColor
public @ColorInt int getTextColor()
Returns the color for rendering the text
getTypeface
public @Nullable Typeface getTypeface()
Gets the current Typeface that is used to style the text.
onInitializeAccessibilityNodeInfo
public void onInitializeAccessibilityNodeInfo(@NonNull AccessibilityNodeInfo info)
onPopulateAccessibilityEvent
public void onPopulateAccessibilityEvent(@NonNull AccessibilityEvent event)
setAnchorAngleDegrees
public void setAnchorAngleDegrees(
@FloatRange(from = 0.0, to = 360.0, toInclusive = true) float value
)
Sets the anchor angle used for positioning the text, in degrees.
setAnchorType
public void setAnchorType(int value)
Sets the anchor type for positioning the curved text.
| Parameters | |
|---|---|
int value |
the anchor type, one of {ANCHOR_START, ANCHOR_CENTER, ANCHOR_END} |
setClockwise
public void setClockwise(boolean value)
Sets the curved text layout direction
setEllipsize
public void setEllipsize(@Nullable TextUtils.TruncateAt value)
Causes words in the text that are longer than the view's width to be ellipsized. Use null to turn off ellipsizing.
setFontFeatureSettings
public void setFontFeatureSettings(@Nullable String value)
Sets font feature settings. The format is the same as the CSS font-feature-settings attribute: https://www.w3.org/TR/css-fonts-3/#font-feature-settings-prop
setFontVariationSettings
public void setFontVariationSettings(@Nullable String value)
Sets TrueType or OpenType font variation settings.
setLetterSpacing
public void setLetterSpacing(float value)
Sets text letter-spacing in ems. Typical values for slight expansion will be around 0.05. Negative values tighten text.
| Parameters | |
|---|---|
float value |
A text letter-space value in ems. |
setSweepAngleDegrees
public void setSweepAngleDegrees(
@FloatRange(from = 0.0, to = 360.0, toInclusive = true) float angleDegrees
)
Set the sweep angle that this widget is drawn with. This is only called during layout, and only if the mWeight is non-zero. Note your widget will need to handle alignment.
setSweepRangeDegrees
public void setSweepRangeDegrees(
@FloatRange(from = 0.0, to = 360.0, toInclusive = true) float minSweep,
@FloatRange(from = 0.0, to = 360.0, toInclusive = true) float maxSweep
)
Sets the minimum and maximum sweep angle in degrees for rendering the text.
| Parameters | |
|---|---|
@FloatRange(from = 0.0, to = 360.0, toInclusive = true) float minSweep |
Ensure the text takes at least this angle (in degrees) in the arc. Use 0f if you don't want to specify a minimum. |
@FloatRange(from = 0.0, to = 360.0, toInclusive = true) float maxSweep |
Limit the maximum angle (in degrees) that this curved text can take. Use 360f if you don't want to specify a maximum. |
setTextColor
public void setTextColor(@ColorInt int value)
Sets the color for rendering the text
setTextSize
public void setTextSize(float value)
Sets the text size for rendering the text
setTypeface
public void setTypeface(@Nullable Typeface value)
Sets the typeface and style in which the text should be displayed. Note that not all Typeface families actually have bold and italic variants
setTypeface
public void setTypeface(@Nullable Typeface tf, int style)
Sets the typeface and style in which the text should be displayed, and turns on the fake bold and italic bits in the Paint if the Typeface that you provided does not have all the bits in the style that you specified.