ActionLabel

public class ActionLabel
extends View

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


This class is deprecated.
along with ActionPage

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

    Inherited constants

    Inherited fields

    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(int unit, float size)

    Limits the text size to no larger than this value.

    void setMaxTextSize(float size)

    Limits the text size to no larger than this value.

    void setMinTextSize(int unit, float size)

    Limits the text size to no smaller than this value.

    void setMinTextSize(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(int color)

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

    void setTextColor(ColorStateList colors)

    Sets the text 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)

    Inherited methods

    Public constructors

    ActionLabel

    public ActionLabel (Context context)

    Parameters
    context Context

    ActionLabel

    public ActionLabel (Context context, 
                    AttributeSet attrs)

    Parameters
    context Context

    attrs AttributeSet

    ActionLabel

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

    Parameters
    context Context

    attrs AttributeSet

    defStyleAttr int

    ActionLabel

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

    Parameters
    context Context

    attrs AttributeSet

    defStyleAttr int

    defStyleRes int

    Public methods

    getCurrentTextColor

    public final int getCurrentTextColor ()

    Return the current color selected for normal text.

    Returns
    int Returns the current text color.

    getGravity

    public int getGravity ()

    Returns the horizontal and vertical alignment of this ActionLabel.

    Returns
    int

    See also:

    getLineSpacingExtra

    public float getLineSpacingExtra ()

    Gets the line spacing extra space

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

    getLineSpacingMultiplier

    public float getLineSpacingMultiplier ()

    Gets the line spacing multiplier

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

    getMaxLines

    public int getMaxLines ()

    Returns
    int

    getTextColors

    public final ColorStateList getTextColors ()

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

    Returns
    ColorStateList

    getTypeface

    public Typeface getTypeface ()

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

    onRtlPropertiesChanged

    public void onRtlPropertiesChanged (int layoutDirection)

    Parameters
    layoutDirection int

    setGravity

    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.

    Parameters
    gravity int

    See also:

    setLineSpacing

    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.

    Parameters
    add float

    mult float

    setMaxLines

    public void setMaxLines (int lines)

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

    Parameters
    lines int

    setMaxTextSize

    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.

    Parameters
    unit int

    size float

    setMaxTextSize

    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.

    Parameters
    size float

    setMinTextSize

    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.

    Parameters
    unit int

    size float

    setMinTextSize

    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 float: interpreted as "scaled pixel" units

    setText

    public void setText (CharSequence text)

    Sets the text to be displayed by this label.

    Parameters
    text CharSequence

    setTextColor

    public void setTextColor (int color)

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

    Parameters
    color int

    setTextColor

    public void setTextColor (ColorStateList colors)

    Sets the text color.

    Parameters
    colors ColorStateList

    setTypeface

    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.

    Parameters
    tf Typeface

    style int

    setTypeface

    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.

    Parameters
    tf Typeface

    See also:

    Protected methods

    drawableStateChanged

    protected void drawableStateChanged ()

    onDraw

    protected void onDraw (Canvas canvas)

    Parameters
    canvas Canvas

    onMeasure

    protected void onMeasure (int widthMeasureSpec, 
                    int heightMeasureSpec)

    Parameters
    widthMeasureSpec int

    heightMeasureSpec int