public class

ActionLabel

extends View

Note: The Wearable Support Library classes under the android.support.wearable package are subject to change. For the full Android API reference, see Reference.

java.lang.Object
   ↳ android.view.View
     ↳ android.support.wearable.view.ActionLabel

Class Overview

ActionLabel is a specialized text display widget. An upper and lower bound for text size and a maximum number of lines are provided and the layout is adjusted automatically to find the largest possible text size satisfying those constraints.

In order to provide a fixed bound, an ActionLabel should always be used with a width and height of "match_parent" or a specific size. When created programmatically, you must supply a LayoutParams to do this:

 LayoutParams lp = new ViewGroup.LayoutParams(200, 50);
 parent.addView(label, lp);
 

Supported attributes are:

  • text
  • textColor
  • maxLines
  • minTextSize
  • maxTextSize
  • lineSpacingExtra
  • lineSpacingMultiplier
  • fontFamily
  • typeface
  • textStyle
  • gravity

Summary

[Expand]
Inherited Constants
From class android.view.View
[Expand]
Inherited Fields
From class android.view.View
Public Constructors
ActionLabel(Context context)
ActionLabel(Context context, AttributeSet attrs)
ActionLabel(Context context, AttributeSet attrs, int defStyleAttr)
ActionLabel(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)
Public Methods
final int getCurrentTextColor()

Return the current color selected for normal text.

int getGravity()
Returns the horizontal and vertical alignment of this ActionLabel.
float getLineSpacingExtra()
Gets the line spacing extra space
float getLineSpacingMultiplier()
Gets the line spacing multiplier
int getMaxLines()
final ColorStateList getTextColors()
Gets the text colors for the different states (normal, selected, focused) of the TextView.
Typeface getTypeface()
void onRtlPropertiesChanged(int layoutDirection)
void setGravity(int gravity)
Sets the horizontal alignment of the text and the vertical gravity that will be used when there is extra space in the ActionLabel beyond what is required for the text itself.
void setLineSpacing(float add, float mult)
Sets line spacing for this TextView.
void setMaxLines(int lines)
Limits the ActionLabel to no more than this many lines tall.
void setMaxTextSize(float size)
Limits the text size to no larger than this value.
void setMaxTextSize(int unit, float size)
Limits the text size to no larger than this value.
void setMinTextSize(float size)
Limits the text size to no smaller than this value.
void setMinTextSize(int unit, float size)
Limits the text size to no smaller than this value.
void setText(CharSequence text)
Sets the text to be displayed by this label.
void setTextColor(ColorStateList colors)
Sets the text color.
void setTextColor(int color)
Sets the text color for all the states (normal, selected, focused) to be this color.
void setTypeface(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.
void setTypeface(Typeface tf)
Sets the typeface and style in which the text should be displayed.
Protected Methods
void drawableStateChanged()
void onDraw(Canvas canvas)
void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
[Expand]
Inherited Methods
From class android.view.View
From class java.lang.Object
From interface android.graphics.drawable.Drawable.Callback
From interface android.view.KeyEvent.Callback
From interface android.view.accessibility.AccessibilityEventSource

Public Constructors

public ActionLabel (Context context)

public ActionLabel (Context context, AttributeSet attrs)

public ActionLabel (Context context, AttributeSet attrs, int defStyleAttr)

public ActionLabel (Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)

Public Methods

public final int getCurrentTextColor ()

Return the current color selected for normal text.

Returns
  • Returns the current text color.

public int getGravity ()

Returns the horizontal and vertical alignment of this ActionLabel.

See Also

public float getLineSpacingExtra ()

Gets the line spacing extra space

Returns
  • the extra space that is added to the height of each lines of this TextView.

public float getLineSpacingMultiplier ()

Gets the line spacing multiplier

Returns
  • the value by which each line's height is multiplied to get its actual height.

public int getMaxLines ()

public final ColorStateList getTextColors ()

Gets the text colors for the different states (normal, selected, focused) of the TextView.

public Typeface getTypeface ()

Returns
  • the current typeface and style in which the text is being displayed.

public void onRtlPropertiesChanged (int layoutDirection)

public void setGravity (int gravity)

Sets the horizontal alignment of the text and the vertical gravity that will be used when there is extra space in the ActionLabel beyond what is required for the text itself.

See Also

public void setLineSpacing (float add, float mult)

Sets line spacing for this TextView. Each line will have its height multiplied by mult and have add added to it.

public void setMaxLines (int lines)

Limits the ActionLabel to no more than this many lines tall.

public void setMaxTextSize (float size)

Limits the text size to no larger than this value. Text will try to be this size if possible, then be reduced in size until it fits available space.

public void setMaxTextSize (int unit, float size)

Limits the text size to no larger than this value. Text will try to be this size if possible, then be reduced in size until it fits available space.

public void setMinTextSize (float size)

Limits the text size to no smaller than this value. Text size is decreased until the content can be rendered within the available space.

Parameters
size interpreted as "scaled pixel" units

public void setMinTextSize (int unit, float size)

Limits the text size to no smaller than this value. Text size is decreased until the content can be rendered within the available space.

public void setText (CharSequence text)

Sets the text to be displayed by this label.

public void setTextColor (ColorStateList colors)

Sets the text color.

public void setTextColor (int color)

Sets the text color for all the states (normal, selected, focused) to be this color.

public void setTypeface (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.

public void setTypeface (Typeface tf)

Sets the typeface and style in which the text should be displayed. Note that not all Typeface families actually have bold and italic variants, so you may need to use setTypeface(Typeface, int) to get the appearance that you actually want.

See Also

Protected Methods

protected void drawableStateChanged ()

protected void onDraw (Canvas canvas)

protected void onMeasure (int widthMeasureSpec, int heightMeasureSpec)