Skip to content

Most visited

Recently visited

navigation

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

    From class android.view.View

    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(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

    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

    ActionLabel

    ActionLabel (Context context)

    Parameters
    context Context

    ActionLabel

    ActionLabel (Context context, 
                    AttributeSet attrs)

    Parameters
    context Context

    attrs AttributeSet

    ActionLabel

    ActionLabel (Context context, 
                    AttributeSet attrs, 
                    int defStyleAttr)

    Parameters
    context Context

    attrs AttributeSet

    defStyleAttr int

    ActionLabel

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

    Parameters
    context Context

    attrs AttributeSet

    defStyleAttr int

    defStyleRes int

    Public methods

    getCurrentTextColor

    int getCurrentTextColor ()

    Return the current color selected for normal text.

    Returns
    int Returns the current text color.

    getGravity

    int getGravity ()

    Returns the horizontal and vertical alignment of this ActionLabel.

    Returns
    int

    See also:

    getLineSpacingExtra

    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

    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

    int getMaxLines ()

    Returns
    int

    getTextColors

    ColorStateList getTextColors ()

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

    Returns
    ColorStateList

    getTypeface

    Typeface getTypeface ()

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

    onRtlPropertiesChanged

    void onRtlPropertiesChanged (int layoutDirection)

    Parameters
    layoutDirection int

    setGravity

    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

    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

    void setMaxLines (int lines)

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

    Parameters
    lines int

    setMaxTextSize

    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

    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

    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

    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

    void setText (CharSequence text)

    Sets the text to be displayed by this label.

    Parameters
    text CharSequence

    setTextColor

    void setTextColor (int color)

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

    Parameters
    color int

    setTextColor

    void setTextColor (ColorStateList colors)

    Sets the text color.

    Parameters
    colors ColorStateList

    setTypeface

    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

    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

    void drawableStateChanged ()

    onDraw

    void onDraw (Canvas canvas)

    Parameters
    canvas Canvas

    onMeasure

    void onMeasure (int widthMeasureSpec, 
                    int heightMeasureSpec)

    Parameters
    widthMeasureSpec int

    heightMeasureSpec int

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Follow Google Developers on WeChat

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience. (April 2018 — Developer Survey)