WearCurvedTextView
public
class
WearCurvedTextView
extends View
implements
WearArcLayout.ArcLayoutWidget
java.lang.Object | ||
↳ | android.view.View | |
↳ | androidx.wear.widget.WearCurvedTextView |
A WearCurvedTextView is a component allowing developers to easily write curved text following the curvature of the largest circle that can be inscribed in the view. WearArcLayout could be used to concatenate multiple curved texts, also layout together with other widgets such as icons.
Summary
Inherited constants |
---|
Inherited fields |
---|
Public constructors | |
---|---|
WearCurvedTextView(Context context)
|
|
WearCurvedTextView(Context context, AttributeSet attrs)
|
|
WearCurvedTextView(Context context, AttributeSet attrs, int defStyle)
|
|
WearCurvedTextView(Context context, AttributeSet attrs, int defStyle, int defStyleRes)
|
Public methods | |
---|---|
void
|
checkInvalidAttributeAsChild()
Check whether the widget contains invalid attributes as a child of WearArcLayout |
void
|
draw(Canvas canvas)
|
float
|
getAnchorAngleDegrees()
Returns the anchor angle used for positioning the text, in degrees. |
int
|
getAnchorType()
returns the anchor type for positioning the curved text |
boolean
|
getClockwise()
returns the curved text layout direction |
TextUtils.TruncateAt
|
getEllipsize()
Returns where, if anywhere, words that are longer than the view is wide should be ellipsized. |
String
|
getFontFeatureSettings()
Returns the font feature settings. |
String
|
getFontVariationSettings()
Returns TrueType or OpenType font variation settings. |
float
|
getLetterSpacing()
Gets the text letter-space value, which determines the spacing between characters. |
float
|
getMaxSweepDegrees()
returns the maximum sweep angle in degrees for rendering the text |
float
|
getMinSweepDegrees()
returns the sweep angle in degrees for rendering the text |
float
|
getSweepAngleDegrees()
Returns the sweep angle that this widget is drawn with. |
String
|
getText()
returns the text to be rendered |
int
|
getTextColor()
returns the color for rendering the text |
float
|
getTextSize()
returns the text size for rendering the text |
int
|
getThicknessPx()
Returns the thickness of this widget inside the arc. |
Typeface
|
getTypeface()
Gets the current Typeface that is used to style the text. |
boolean
|
insideClickArea(float x, float y)
Return true when the given point is in the clickable area of the child widget. |
boolean
|
onTouchEvent(MotionEvent event)
|
void
|
setAnchorAngleDegrees(float value)
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(TextUtils.TruncateAt value)
Causes words in the text that are longer than the view's width to be ellipsized. |
void
|
setFontFeatureSettings(String value)
Sets font feature settings. |
void
|
setFontVariationSettings(String value)
Sets TrueType or OpenType font variation settings. |
void
|
setLetterSpacing(float value)
Sets text letter-spacing in ems. |
void
|
setMaxSweepDegrees(float value)
sets the maximum sweep angle in degrees for rendering the text |
void
|
setMinSweepDegrees(float value)
sets the sweep angle in degrees for rendering the text |
void
|
setText(String value)
sets the text to be rendered |
void
|
setTextColor(int value)
sets the color for rendering the text |
void
|
setTextSize(float value)
sets the text size for rendering the text |
void
|
setTypeface(Typeface value)
Sets the typeface and style in which the text should be displayed. |
Protected methods | |
---|---|
void
|
onDraw(Canvas canvas)
|
void
|
onLayout(boolean changed, int l, int t, int r, int b)
|
void
|
onSizeChanged(int w, int h, int oldw, int oldh)
|
Inherited methods | |
---|---|
Public constructors
WearCurvedTextView
public WearCurvedTextView (Context context, AttributeSet attrs)
Parameters | |
---|---|
context |
Context |
attrs |
AttributeSet |
WearCurvedTextView
public WearCurvedTextView (Context context, AttributeSet attrs, int defStyle)
Parameters | |
---|---|
context |
Context |
attrs |
AttributeSet |
defStyle |
int |
WearCurvedTextView
public WearCurvedTextView (Context context, AttributeSet attrs, int defStyle, int defStyleRes)
Parameters | |
---|---|
context |
Context |
attrs |
AttributeSet |
defStyle |
int |
defStyleRes |
int |
Public methods
checkInvalidAttributeAsChild
public void checkInvalidAttributeAsChild ()
Check whether the widget contains invalid attributes as a child of WearArcLayout
Throws | |
---|---|
IllegalArgumentException |
if the anchorType and/or anchorAngleDegrees attributes were set for a widget in WearArcLayout |
getAnchorAngleDegrees
public float getAnchorAngleDegrees ()
Returns the anchor angle used for positioning the text, in degrees.
Returns | |
---|---|
float |
getAnchorType
public int getAnchorType ()
returns the anchor type for positioning the curved text
Returns | |
---|---|
int |
getClockwise
public boolean getClockwise ()
returns the curved text layout direction
Returns | |
---|---|
boolean |
getEllipsize
public TextUtils.TruncateAt getEllipsize ()
Returns where, if anywhere, words that are longer than the view is wide should be ellipsized.
Returns | |
---|---|
TextUtils.TruncateAt |
getFontFeatureSettings
public 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
Returns | |
---|---|
String |
the currently set font feature settings. Default is null. |
getFontVariationSettings
public String getFontVariationSettings ()
Returns TrueType or OpenType font variation settings.
Returns | |
---|---|
String |
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 float getMaxSweepDegrees ()
returns the maximum sweep angle in degrees for rendering the text
Returns | |
---|---|
float |
getMinSweepDegrees
public float getMinSweepDegrees ()
returns the sweep angle in degrees for rendering the text
Returns | |
---|---|
float |
getSweepAngleDegrees
public float getSweepAngleDegrees ()
Returns the sweep angle that this widget is drawn with.
Returns | |
---|---|
float |
getText
public String getText ()
returns the text to be rendered
Returns | |
---|---|
String |
getTextColor
public int getTextColor ()
returns the color for rendering the text
Returns | |
---|---|
int |
getTextSize
public float getTextSize ()
returns the text size for rendering the text
Returns | |
---|---|
float |
getThicknessPx
public int getThicknessPx ()
Returns the thickness of this widget inside the arc.
Returns | |
---|---|
int |
getTypeface
public Typeface getTypeface ()
Gets the current Typeface that is used to style the text.
Returns | |
---|---|
Typeface |
insideClickArea
public boolean insideClickArea (float x, float y)
Return true when the given point is in the clickable area of the child widget. In particular, the coordinates should be considered as if the child was drawn centered at the default angle (12 o clock).
Parameters | |
---|---|
x |
float |
y |
float |
Returns | |
---|---|
boolean |
onTouchEvent
public boolean onTouchEvent (MotionEvent event)
Parameters | |
---|---|
event |
MotionEvent |
Returns | |
---|---|
boolean |
setAnchorAngleDegrees
public void setAnchorAngleDegrees (float value)
Sets the anchor angle used for positioning the text, in degrees.
Parameters | |
---|---|
value |
float |
setAnchorType
public void setAnchorType (int value)
Sets the anchor type for positioning the curved text.
Parameters | |
---|---|
value |
int : the anchor type, one of {ANCHOR_START, ANCHOR_CENTER, ANCHOR_END}
|
setClockwise
public void setClockwise (boolean value)
sets the curved text layout direction
Parameters | |
---|---|
value |
boolean |
setEllipsize
public void setEllipsize (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.
Parameters | |
---|---|
value |
TextUtils.TruncateAt |
setFontFeatureSettings
public void setFontFeatureSettings (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
Parameters | |
---|---|
value |
String : font feature settings represented as CSS compatible string. This value may be
null.
|
setFontVariationSettings
public void setFontVariationSettings (String value)
Sets TrueType or OpenType font variation settings.
Parameters | |
---|---|
value |
String : font variation settings. You can pass null or empty string as no variation
settings. This value may be null
|
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 | |
---|---|
value |
float : A text letter-space value in ems.
|
setMaxSweepDegrees
public void setMaxSweepDegrees (float value)
sets the maximum sweep angle in degrees for rendering the text
Parameters | |
---|---|
value |
float |
setMinSweepDegrees
public void setMinSweepDegrees (float value)
sets the sweep angle in degrees for rendering the text
Parameters | |
---|---|
value |
float |
setText
public void setText (String value)
sets the text to be rendered
Parameters | |
---|---|
value |
String |
setTextColor
public void setTextColor (int value)
sets the color for rendering the text
Parameters | |
---|---|
value |
int |
setTextSize
public void setTextSize (float value)
sets the text size for rendering the text
Parameters | |
---|---|
value |
float |
setTypeface
public void setTypeface (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
Parameters | |
---|---|
value |
Typeface |
Protected methods
onLayout
protected void onLayout (boolean changed, int l, int t, int r, int b)
Parameters | |
---|---|
changed |
boolean |
l |
int |
t |
int |
r |
int |
b |
int |
onSizeChanged
protected void onSizeChanged (int w, int h, int oldw, int oldh)
Parameters | |
---|---|
w |
int |
h |
int |
oldw |
int |
oldh |
int |