Register now for Android Dev Summit 2019!

ChipDrawable

public class ChipDrawable
extends MaterialShapeDrawable implements TintAwareDrawable, Drawable.Callback

java.lang.Object
   ↳ android.graphics.drawable.Drawable
     ↳ com.google.android.material.shape.MaterialShapeDrawable
       ↳ com.google.android.material.chip.ChipDrawable


ChipDrawable contains all the layout and draw logic for Chip.

You can use ChipDrawable directly in contexts that require a Drawable. For example, an auto-complete enabled EditText can replace snippets of text with a ChipDrawable to represent it as a semantic entity. To create an instance of ChipDrawable, use createFromResource(Context, int) and pass in an XML resource in this form:

<chip xmlns:app="http://schemas.android.com/apk/res-auto"
     android:text="Hello, World!"/>
 

The basic attributes you can set are:

  • android:checkable - If true, the chip can be toggled. If false, the chip acts like a button.
  • android:text - Sets the text of the chip.
  • app:chipIcon - Sets the icon of the chip, or use @null to display no icon. Usually on the left.
  • app:checkedIcon - Sets a custom icon to use when checked, or use @null to display no icon. Usually on the left.
  • app:closeIcon - Sets a custom icon that the user can click to close, or use @null to display no icon. Usually on the right.
  • ellipsize - Does not support MARQUEE because chip text should not scroll.

When used in this stand-alone mode, the host view must explicitly manage the ChipDrawable's state:

ChipDrawable's horizontal layout is as follows:

   chipStartPadding     iconEndPadding     closeIconStartPadding         chipEndPadding
    +                    +                                    +                      +
    |                    |                                    |                      |
    |  iconStartPadding  |  textStartPadding   textEndPadding | closeIconEndPadding  |
    |   +                |    +                            +  |                  +   |
    |   |                |    |                            |  |                  |   |
    v   v                v    v                            v  v                  v   v
 +-----+----+-----------+----+----+---------------------+----+----+----------+----+-----+
 |     |    |       XX  |    |    |  XX   X  X  X  XXX  |    |    | X      X |    |     |
 |     |    |      XX   |    |    | X  X  X  X  X  X  X |    |    |  XX  XX  |    |     |
 |     |    |  XX XX    |    |    | X     XXXX  X  XXX  |    |    |    XX    |    |     |
 |     |    |   XXX     |    |    | X  X  X  X  X  X    |    |    |  XX  XX  |    |     |
 |     |    |    X      |    |    |  XX   X  X  X  X    |    |    | X      X |    |     |
 +-----+----+-----------+----+----+---------------------+----+----+----------+----+-----+
                  ^                           ^                         ^
                  |                           |                         |
                  +                           +                         +
             chipIconSize                  *dynamic*              closeIconSize
 

ChipDrawable contains three child drawables: ERROR(/#chipIcon), ERROR(/#checkedIcon), and ERROR(/#closeIcon). chipIcon and checkedIcon inherit the state of this drawable, but closeIcon contains its own state that you can set with setCloseIconState(int[]).

See also:

Summary

Nested classes

interface ChipDrawable.Delegate

Delegate interface to be implemented by Views that own a ChipDrawable. 

XML attributes

Chip_checkedIcon  
Chip_chipBackgroundColor  
Chip_chipCornerRadius  
Chip_chipEndPadding  
Chip_chipIconTint  
Chip_chipMinHeight  
Chip_chipStartPadding  
Chip_chipStrokeColor  
Chip_chipStrokeWidth  
Chip_closeIconEndPadding  
Chip_closeIconStartPadding  
Chip_hideMotionSpec  
Chip_iconEndPadding  
Chip_iconStartPadding  
Chip_rippleColor  
Chip_showMotionSpec  
Chip_textEndPadding  
Chip_textStartPadding  

Inherited constants

From class com.google.android.material.shape.MaterialShapeDrawable

Public methods

static ChipDrawable createFromAttributes(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)

Returns a ChipDrawable from the given attributes.

static ChipDrawable createFromResource(Context context, int id)

Returns a ChipDrawable from the given XML resource.

void draw(Canvas canvas)
int getAlpha()
Drawable getCheckedIcon()

Returns this chip's checked icon.

ColorStateList getChipBackgroundColor()

Returns this chip's background color.

float getChipCornerRadius()

Returns this chip's corner radius.

float getChipEndPadding()

Returns this chip's end padding.

Drawable getChipIcon()
float getChipIconSize()
ColorStateList getChipIconTint()

Returns the ColorStateList used to tint the chip icon.

float getChipMinHeight()

Returns this chip's minimum height.

float getChipStartPadding()

Returns this chip's start padding.

ColorStateList getChipStrokeColor()

Returns this chip's stroke color.

float getChipStrokeWidth()

Returns this chip's stroke width.

void getChipTouchBounds(RectF bounds)

Returns the chip's ChipDrawable-absolute bounds (top-left is [ChipDrawable.getBounds().left, ChipDrawable.getBounds().top]).

Drawable getCloseIcon()
CharSequence getCloseIconContentDescription()
float getCloseIconEndPadding()

Returns the end padding for this chip's close icon.

float getCloseIconSize()
float getCloseIconStartPadding()

Returns the start padding for this chip's close icon.

int[] getCloseIconState()

Describes the current state of the close icon.

ColorStateList getCloseIconTint()
void getCloseIconTouchBounds(RectF bounds)

Returns the close icon's ChipDrawable-absolute bounds (top-left is [ChipDrawable.getBounds().left, ChipDrawable.getBounds().top]).

ColorFilter getColorFilter()
TextUtils.TruncateAt getEllipsize()
MotionSpec getHideMotionSpec()

Returns this chip's hide motion spec.

float getIconEndPadding()

Returns the end padding for this chip's icon.

float getIconStartPadding()

Returns the start padding for this chip's icon.

int getIntrinsicHeight()

Returns the height at which the chip would like to be laid out.

int getIntrinsicWidth()

Returns the width at which the chip would like to be laid out.

int getMaxWidth()

Returns the maximum width of TextView in terms of pixels.

int getOpacity()
void getOutline(Outline outline)
ColorStateList getRippleColor()

Returns this chip's ripple color.

MotionSpec getShowMotionSpec()

Returns this chip's show motion spec.

CharSequence getText()
TextAppearance getTextAppearance()
float getTextEndPadding()

Returns the end padding for this chip's text.

float getTextStartPadding()

Returns the start padding for this chip's text.

boolean getUseCompatRipple()

Returns whether this ChipDrawable should draw its own compatibility ripples.

void invalidateDrawable(Drawable who)
boolean isCheckable()
boolean isCheckedIconEnabled()

This method is deprecated. Use isCheckedIconVisible() instead.

boolean isCheckedIconVisible()
boolean isChipIconEnabled()

This method is deprecated. Use isChipIconVisible() instead.

boolean isChipIconVisible()
boolean isCloseIconEnabled()

This method is deprecated. Use isCloseIconVisible() instead.

boolean isCloseIconStateful()

Indicates whether the close icon drawable will change its appearance based on state.

boolean isCloseIconVisible()
boolean isStateful()

Indicates whether this chip drawable will change its appearance based on state.

boolean onLayoutDirectionChanged(int layoutDirection)
boolean onStateChange(int[] state)
void onTextSizeChange()
void scheduleDrawable(Drawable who, Runnable what, long when)
void setAlpha(int alpha)

Sets the alpha of this ChipDrawable.

void setCheckable(boolean checkable)
void setCheckableResource(int id)
void setCheckedIcon(Drawable checkedIcon)

Sets this chip's checked icon.

void setCheckedIconEnabled(boolean checkedIconEnabled)

This method is deprecated. Use setCheckedIconVisible(boolean) instead.

void setCheckedIconEnabledResource(int id)

This method is deprecated. Use setCheckedIconVisible(int) instead.

void setCheckedIconResource(int id)

Sets this chip's checked icon using a resource id.

void setCheckedIconVisible(int id)
void setCheckedIconVisible(boolean checkedIconVisible)
void setChipBackgroundColor(ColorStateList chipBackgroundColor)

Sets this chip's background color.

void setChipBackgroundColorResource(int id)

Sets this chip's background color using a resource id.

void setChipCornerRadius(float chipCornerRadius)

This method is deprecated. Use setAllCorners(int, int) instead.

void setChipCornerRadiusResource(int id)

This method is deprecated. Use setAllCorners(int, int) instead.

void setChipEndPadding(float chipEndPadding)

Sets this chip's end padding.

void setChipEndPaddingResource(int id)

Sets this chip's end padding using a resource id.

void setChipIcon(Drawable chipIcon)
void setChipIconEnabled(boolean chipIconEnabled)

This method is deprecated. Use setChipIconVisible(boolean) instead.

void setChipIconEnabledResource(int id)

This method is deprecated. Use setChipIconVisible(int) instead.

void setChipIconResource(int id)
void setChipIconSize(float chipIconSize)
void setChipIconSizeResource(int id)
void setChipIconTint(ColorStateList chipIconTint)

Sets the chip icon's color tint using the specified ColorStateList.

void setChipIconTintResource(int id)

Sets the chip icon's color tint using a resource ID.

void setChipIconVisible(int id)
void setChipIconVisible(boolean chipIconVisible)
void setChipMinHeight(float chipMinHeight)

Sets this chip's minimum height.

void setChipMinHeightResource(int id)

Sets this chip's minimum height using a resource id.

void setChipStartPadding(float chipStartPadding)

Sets this chip's start padding.

void setChipStartPaddingResource(int id)

Sets this chip's start padding using a resource id.

void setChipStrokeColor(ColorStateList chipStrokeColor)

Sets this chip's stroke color.

void setChipStrokeColorResource(int id)

Sets this chip's stroke color using a resource id.

void setChipStrokeWidth(float chipStrokeWidth)

Sets this chip's stroke width.

void setChipStrokeWidthResource(int id)

Sets this chip's stroke width using a resource id.

void setCloseIcon(Drawable closeIcon)
void setCloseIconContentDescription(CharSequence closeIconContentDescription)
void setCloseIconEnabled(boolean closeIconEnabled)

This method is deprecated. Use setCloseIconVisible(int) instead.

void setCloseIconEnabledResource(int id)

This method is deprecated. Use setCloseIconVisible(int) instead.

void setCloseIconEndPadding(float closeIconEndPadding)

Sets the end padding for this chip's close icon.

void setCloseIconEndPaddingResource(int id)

Sets the end padding for this chip's close icon using a resource id.

void setCloseIconResource(int id)
void setCloseIconSize(float closeIconSize)
void setCloseIconSizeResource(int id)
void setCloseIconStartPadding(float closeIconStartPadding)

Sets the start padding for this chip's close icon.

void setCloseIconStartPaddingResource(int id)

Sets the start padding for this chip's close icon using a resource id.

boolean setCloseIconState(int[] stateSet)

Specify a set of states for the close icon.

void setCloseIconTint(ColorStateList closeIconTint)
void setCloseIconTintResource(int id)
void setCloseIconVisible(boolean closeIconVisible)
void setCloseIconVisible(int id)
void setColorFilter(ColorFilter colorFilter)
void setDelegate(ChipDrawable.Delegate delegate)

Sets the View delegate that owns this ChipDrawable.

void setEllipsize(TextUtils.TruncateAt truncateAt)
void setHideMotionSpec(MotionSpec hideMotionSpec)

Sets this chip's hide motion spec.

void setHideMotionSpecResource(int id)

Sets this chip's hide motion spec using a resource id.

void setIconEndPadding(float iconEndPadding)

Sets the end padding for this chip's icon.

void setIconEndPaddingResource(int id)

Sets the end padding for this chip's icon using a resource id.

void setIconStartPadding(float iconStartPadding)

Sets this chip's icon start padding.

void setIconStartPaddingResource(int id)

Sets the start padding for this chip's icon using a resource id.

void setMaxWidth(int maxWidth)

Sets the width of the TextView to be exactly pixels wide.

void setRippleColor(ColorStateList rippleColor)

Sets this chip's ripple color.

void setRippleColorResource(int id)

Sets this chip's ripple color using a resource id.

void setShowMotionSpec(MotionSpec showMotionSpec)

Sets this chip's show motion spec.

void setShowMotionSpecResource(int id)

Sets this chip's show motion spec using a resource id.

void setText(CharSequence text)
void setTextAppearance(TextAppearance textAppearance)
void setTextAppearanceResource(int id)
void setTextEndPadding(float textEndPadding)

Sets the end padding for this chip's text.

void setTextEndPaddingResource(int id)

Sets the end padding for this chip's text using a resource id.

void setTextResource(int id)
void setTextStartPadding(float textStartPadding)

Sets the start padding for this chip's text.

void setTextStartPaddingResource(int id)

Sets the start padding for this chip's text using a resource id.

void setTintList(ColorStateList tint)
void setTintMode(PorterDuff.Mode tintMode)
void setUseCompatRipple(boolean useCompatRipple)

Sets whether this ChipDrawable should draw its own compatibility ripples.

boolean setVisible(boolean visible, boolean restart)
void unscheduleDrawable(Drawable who, Runnable what)

Protected methods

boolean onLevelChange(int level)
void onSizeChange()

Attempts to call onChipDrawableSizeChange() on the delegate.

Inherited methods

From class com.google.android.material.shape.MaterialShapeDrawable
From class android.graphics.drawable.Drawable
From class java.lang.Object
From interface androidx.core.graphics.drawable.TintAwareDrawable
From interface com.google.android.material.shape.ShapeAppearanceModel.OnChangedListener
From interface android.graphics.drawable.Drawable.Callback

XML attributes

Chip_checkedIcon

Related methods:

Chip_chipBackgroundColor

Related methods:

Chip_chipCornerRadius

Related methods:

Chip_chipEndPadding

Related methods:

Chip_chipIconTint

Related methods:

Chip_chipMinHeight

Related methods:

Chip_chipStartPadding

Related methods:

Chip_chipStrokeColor

Related methods:

Chip_chipStrokeWidth

Related methods:

Chip_closeIconEndPadding

Related methods:

Chip_closeIconStartPadding

Related methods:

Chip_hideMotionSpec

Related methods:

Chip_iconEndPadding

Related methods:

Chip_iconStartPadding

Related methods:

Chip_rippleColor

Related methods:

Chip_showMotionSpec

Related methods:

Chip_textEndPadding

Related methods:

Chip_textStartPadding

Related methods:

Public methods

createFromAttributes

ChipDrawable createFromAttributes (Context context, 
                AttributeSet attrs, 
                int defStyleAttr, 
                int defStyleRes)

Returns a ChipDrawable from the given attributes.

Parameters
context Context

attrs AttributeSet

defStyleAttr int

defStyleRes int

Returns
ChipDrawable

createFromResource

ChipDrawable createFromResource (Context context, 
                int id)

Returns a ChipDrawable from the given XML resource. All attributes from Chip and a custom style attribute are supported. A chip resource may look like:

<chip
     xmlns:app="http://schemas.android.com/apk/res-auto"
     style="@style/Widget.MaterialComponents.Chip.Entry"
     app:chipIcon="@drawable/custom_icon"/>
 

Parameters
context Context

id int

Returns
ChipDrawable

draw

void draw (Canvas canvas)

Parameters
canvas Canvas

getAlpha

int getAlpha ()

Returns
int

getCheckedIcon

Drawable getCheckedIcon ()

Returns this chip's checked icon.

Related XML Attributes:

Returns
Drawable

getChipBackgroundColor

ColorStateList getChipBackgroundColor ()

Returns this chip's background color.

Related XML Attributes:

Returns
ColorStateList

getChipCornerRadius

float getChipCornerRadius ()

Returns this chip's corner radius.

Related XML Attributes:

Returns
float

getChipEndPadding

float getChipEndPadding ()

Returns this chip's end padding.

Related XML Attributes:

Returns
float

getChipIcon

Drawable getChipIcon ()

Returns
Drawable

getChipIconSize

float getChipIconSize ()

Returns
float

getChipIconTint

ColorStateList getChipIconTint ()

Returns the ColorStateList used to tint the chip icon.

Returns
ColorStateList

getChipMinHeight

float getChipMinHeight ()

Returns this chip's minimum height.

Related XML Attributes:

Returns
float

getChipStartPadding

float getChipStartPadding ()

Returns this chip's start padding.

Related XML Attributes:

Returns
float

getChipStrokeColor

ColorStateList getChipStrokeColor ()

Returns this chip's stroke color.

Related XML Attributes:

Returns
ColorStateList

getChipStrokeWidth

float getChipStrokeWidth ()

Returns this chip's stroke width.

Related XML Attributes:

Returns
float

getChipTouchBounds

void getChipTouchBounds (RectF bounds)

Returns the chip's ChipDrawable-absolute bounds (top-left is [ChipDrawable.getBounds().left, ChipDrawable.getBounds().top]).

Parameters
bounds RectF

getCloseIcon

Drawable getCloseIcon ()

Returns
Drawable

getCloseIconContentDescription

CharSequence getCloseIconContentDescription ()

Returns
CharSequence

getCloseIconEndPadding

float getCloseIconEndPadding ()

Returns the end padding for this chip's close icon.

Related XML Attributes:

Returns
float

getCloseIconSize

float getCloseIconSize ()

Returns
float

getCloseIconStartPadding

float getCloseIconStartPadding ()

Returns the start padding for this chip's close icon.

Related XML Attributes:

Returns
float

getCloseIconState

int[] getCloseIconState ()

Describes the current state of the close icon.

Returns
int[]

getCloseIconTint

ColorStateList getCloseIconTint ()

Returns
ColorStateList

getCloseIconTouchBounds

void getCloseIconTouchBounds (RectF bounds)

Returns the close icon's ChipDrawable-absolute bounds (top-left is [ChipDrawable.getBounds().left, ChipDrawable.getBounds().top]).

Parameters
bounds RectF

getColorFilter

ColorFilter getColorFilter ()

Returns
ColorFilter

getEllipsize

TextUtils.TruncateAt getEllipsize ()

Returns
TextUtils.TruncateAt

getHideMotionSpec

MotionSpec getHideMotionSpec ()

Returns this chip's hide motion spec.

Related XML Attributes:

Returns
MotionSpec

getIconEndPadding

float getIconEndPadding ()

Returns the end padding for this chip's icon.

Related XML Attributes:

Returns
float

getIconStartPadding

float getIconStartPadding ()

Returns the start padding for this chip's icon.

Related XML Attributes:

Returns
float

getIntrinsicHeight

int getIntrinsicHeight ()

Returns the height at which the chip would like to be laid out.

Returns
int

getIntrinsicWidth

int getIntrinsicWidth ()

Returns the width at which the chip would like to be laid out.

Returns
int

getMaxWidth

int getMaxWidth ()

Returns the maximum width of TextView in terms of pixels.

Returns
int

See also:

getOpacity

int getOpacity ()

Returns
int

getOutline

void getOutline (Outline outline)

Parameters
outline Outline

getRippleColor

ColorStateList getRippleColor ()

Returns this chip's ripple color.

Related XML Attributes:

Returns
ColorStateList

getShowMotionSpec

MotionSpec getShowMotionSpec ()

Returns this chip's show motion spec.

Related XML Attributes:

Returns
MotionSpec

getText

CharSequence getText ()

Returns
CharSequence

getTextAppearance

TextAppearance getTextAppearance ()

Returns
TextAppearance

getTextEndPadding

float getTextEndPadding ()

Returns the end padding for this chip's text.

Related XML Attributes:

Returns
float

getTextStartPadding

float getTextStartPadding ()

Returns the start padding for this chip's text.

Related XML Attributes:

Returns
float

getUseCompatRipple

boolean getUseCompatRipple ()

Returns whether this ChipDrawable should draw its own compatibility ripples.

Returns
boolean

invalidateDrawable

void invalidateDrawable (Drawable who)

Parameters
who Drawable

isCheckable

boolean isCheckable ()

Returns
boolean

isCheckedIconEnabled

boolean isCheckedIconEnabled ()

This method is deprecated.
Use isCheckedIconVisible() instead.

Returns
boolean

isCheckedIconVisible

boolean isCheckedIconVisible ()

Returns
boolean

isChipIconEnabled

boolean isChipIconEnabled ()

This method is deprecated.
Use isChipIconVisible() instead.

Returns
boolean

isChipIconVisible

boolean isChipIconVisible ()

Returns
boolean

isCloseIconEnabled

boolean isCloseIconEnabled ()

This method is deprecated.
Use isCloseIconVisible() instead.

Returns
boolean

isCloseIconStateful

boolean isCloseIconStateful ()

Indicates whether the close icon drawable will change its appearance based on state.

Returns
boolean

isCloseIconVisible

boolean isCloseIconVisible ()

Returns
boolean

isStateful

boolean isStateful ()

Indicates whether this chip drawable will change its appearance based on state.

Returns
boolean

onLayoutDirectionChanged

boolean onLayoutDirectionChanged (int layoutDirection)

Parameters
layoutDirection int

Returns
boolean

onStateChange

boolean onStateChange (int[] state)

Parameters
state int

Returns
boolean

onTextSizeChange

void onTextSizeChange ()

scheduleDrawable

void scheduleDrawable (Drawable who, 
                Runnable what, 
                long when)

Parameters
who Drawable

what Runnable

when long

setAlpha

void setAlpha (int alpha)

Sets the alpha of this ChipDrawable. This will drastically decrease draw performance. You are highly encouraged to use setAlpha(float) instead.

Parameters
alpha int

setCheckable

void setCheckable (boolean checkable)

Parameters
checkable boolean

setCheckableResource

void setCheckableResource (int id)

Parameters
id int

setCheckedIcon

void setCheckedIcon (Drawable checkedIcon)

Sets this chip's checked icon.

Related XML Attributes:

Parameters
checkedIcon Drawable: This chip's checked icon.

setCheckedIconEnabled

void setCheckedIconEnabled (boolean checkedIconEnabled)

This method is deprecated.
Use setCheckedIconVisible(boolean) instead.

Parameters
checkedIconEnabled boolean

setCheckedIconEnabledResource

void setCheckedIconEnabledResource (int id)

This method is deprecated.
Use setCheckedIconVisible(int) instead.

Parameters
id int

setCheckedIconResource

void setCheckedIconResource (int id)

Sets this chip's checked icon using a resource id.

Related XML Attributes:

Parameters
id int: The resource id of this chip's checked icon.

setCheckedIconVisible

void setCheckedIconVisible (int id)

Parameters
id int

setCheckedIconVisible

void setCheckedIconVisible (boolean checkedIconVisible)

Parameters
checkedIconVisible boolean

setChipBackgroundColor

void setChipBackgroundColor (ColorStateList chipBackgroundColor)

Sets this chip's background color.

Related XML Attributes:

Parameters
chipBackgroundColor ColorStateList: This chip's background color.

setChipBackgroundColorResource

void setChipBackgroundColorResource (int id)

Sets this chip's background color using a resource id.

Related XML Attributes:

Parameters
id int: The resource id of this chip's background color.

setChipCornerRadius

void setChipCornerRadius (float chipCornerRadius)

This method is deprecated.
Use setAllCorners(int, int) instead.

Parameters
chipCornerRadius float

setChipCornerRadiusResource

void setChipCornerRadiusResource (int id)

This method is deprecated.
Use setAllCorners(int, int) instead.

Parameters
id int

setChipEndPadding

void setChipEndPadding (float chipEndPadding)

Sets this chip's end padding.

Related XML Attributes:

Parameters
chipEndPadding float: This chip's end padding.

setChipEndPaddingResource

void setChipEndPaddingResource (int id)

Sets this chip's end padding using a resource id.

Related XML Attributes:

Parameters
id int: The resource id for this chip's end padding.

setChipIcon

void setChipIcon (Drawable chipIcon)

Parameters
chipIcon Drawable

setChipIconEnabled

void setChipIconEnabled (boolean chipIconEnabled)

This method is deprecated.
Use setChipIconVisible(boolean) instead.

Parameters
chipIconEnabled boolean

setChipIconEnabledResource

void setChipIconEnabledResource (int id)

This method is deprecated.
Use setChipIconVisible(int) instead.

Parameters
id int

setChipIconResource

void setChipIconResource (int id)

Parameters
id int

setChipIconSize

void setChipIconSize (float chipIconSize)

Parameters
chipIconSize float

setChipIconSizeResource

void setChipIconSizeResource (int id)

Parameters
id int

setChipIconTint

void setChipIconTint (ColorStateList chipIconTint)

Sets the chip icon's color tint using the specified ColorStateList.

Related XML Attributes:

Parameters
chipIconTint ColorStateList: ColorStateList to tint the chip icon.

setChipIconTintResource

void setChipIconTintResource (int id)

Sets the chip icon's color tint using a resource ID.

Related XML Attributes:

Parameters
id int: Resource id of a ColorStateList to tint the chip icon.

setChipIconVisible

void setChipIconVisible (int id)

Parameters
id int

setChipIconVisible

void setChipIconVisible (boolean chipIconVisible)

Parameters
chipIconVisible boolean

setChipMinHeight

void setChipMinHeight (float chipMinHeight)

Sets this chip's minimum height.

Related XML Attributes:

Parameters
chipMinHeight float: This chip's mininum height.

setChipMinHeightResource

void setChipMinHeightResource (int id)

Sets this chip's minimum height using a resource id.

Related XML Attributes:

Parameters
id int: The resource id of this chip's mininum height.

setChipStartPadding

void setChipStartPadding (float chipStartPadding)

Sets this chip's start padding.

Related XML Attributes:

Parameters
chipStartPadding float: This chip's start padding.

setChipStartPaddingResource

void setChipStartPaddingResource (int id)

Sets this chip's start padding using a resource id.

Related XML Attributes:

Parameters
id int: The resource id of this chip's start padding.

setChipStrokeColor

void setChipStrokeColor (ColorStateList chipStrokeColor)

Sets this chip's stroke color.

Related XML Attributes:

Parameters
chipStrokeColor ColorStateList: This chip's stroke color.

setChipStrokeColorResource

void setChipStrokeColorResource (int id)

Sets this chip's stroke color using a resource id.

Related XML Attributes:

Parameters
id int: The resource id of this chip's stroke color.

setChipStrokeWidth

void setChipStrokeWidth (float chipStrokeWidth)

Sets this chip's stroke width.

Related XML Attributes:

Parameters
chipStrokeWidth float: This chip's stroke width.

setChipStrokeWidthResource

void setChipStrokeWidthResource (int id)

Sets this chip's stroke width using a resource id.

Related XML Attributes:

Parameters
id int: The resource id of this chip's stroke width.

setCloseIcon

void setCloseIcon (Drawable closeIcon)

Parameters
closeIcon Drawable

setCloseIconContentDescription

void setCloseIconContentDescription (CharSequence closeIconContentDescription)

Parameters
closeIconContentDescription CharSequence

setCloseIconEnabled

void setCloseIconEnabled (boolean closeIconEnabled)

This method is deprecated.
Use setCloseIconVisible(int) instead.

Parameters
closeIconEnabled boolean

setCloseIconEnabledResource

void setCloseIconEnabledResource (int id)

This method is deprecated.
Use setCloseIconVisible(int) instead.

Parameters
id int

setCloseIconEndPadding

void setCloseIconEndPadding (float closeIconEndPadding)

Sets the end padding for this chip's close icon.

Related XML Attributes:

Parameters
closeIconEndPadding float: The end padding of this chip's close icon.

setCloseIconEndPaddingResource

void setCloseIconEndPaddingResource (int id)

Sets the end padding for this chip's close icon using a resource id.

Related XML Attributes:

Parameters
id int: The resource id for the end padding of this chip's close icon.

setCloseIconResource

void setCloseIconResource (int id)

Parameters
id int

setCloseIconSize

void setCloseIconSize (float closeIconSize)

Parameters
closeIconSize float

setCloseIconSizeResource

void setCloseIconSizeResource (int id)

Parameters
id int

setCloseIconStartPadding

void setCloseIconStartPadding (float closeIconStartPadding)

Sets the start padding for this chip's close icon.

Related XML Attributes:

Parameters
closeIconStartPadding float: The start padding of this chip's close icon.

setCloseIconStartPaddingResource

void setCloseIconStartPaddingResource (int id)

Sets the start padding for this chip's close icon using a resource id.

Related XML Attributes:

Parameters
id int: The resource id for the start padding of this chip's close icon.

setCloseIconState

boolean setCloseIconState (int[] stateSet)

Specify a set of states for the close icon. This is a separate state set than the one used for the rest of the chip.

Parameters
stateSet int

Returns
boolean

setCloseIconTint

void setCloseIconTint (ColorStateList closeIconTint)

Parameters
closeIconTint ColorStateList

setCloseIconTintResource

void setCloseIconTintResource (int id)

Parameters
id int

setCloseIconVisible

void setCloseIconVisible (boolean closeIconVisible)

Parameters
closeIconVisible boolean

setCloseIconVisible

void setCloseIconVisible (int id)

Parameters
id int

setColorFilter

void setColorFilter (ColorFilter colorFilter)

Parameters
colorFilter ColorFilter

setDelegate

void setDelegate (ChipDrawable.Delegate delegate)

Sets the View delegate that owns this ChipDrawable.

Parameters
delegate ChipDrawable.Delegate

setEllipsize

void setEllipsize (TextUtils.TruncateAt truncateAt)

Parameters
truncateAt TextUtils.TruncateAt

setHideMotionSpec

void setHideMotionSpec (MotionSpec hideMotionSpec)

Sets this chip's hide motion spec.

Related XML Attributes:

Parameters
hideMotionSpec MotionSpec: This chip's hide motion spec.

setHideMotionSpecResource

void setHideMotionSpecResource (int id)

Sets this chip's hide motion spec using a resource id.

Related XML Attributes:

Parameters
id int: The resource id of this chip's hide motion spec.

setIconEndPadding

void setIconEndPadding (float iconEndPadding)

Sets the end padding for this chip's icon.

Related XML Attributes:

Parameters
iconEndPadding float: The end padding of this chip's icon.

setIconEndPaddingResource

void setIconEndPaddingResource (int id)

Sets the end padding for this chip's icon using a resource id.

Related XML Attributes:

Parameters
id int: The resource id for the end padding of this chip's icon.

setIconStartPadding

void setIconStartPadding (float iconStartPadding)

Sets this chip's icon start padding.

Related XML Attributes:

Parameters
iconStartPadding float: The start padding of this chip's icon.

setIconStartPaddingResource

void setIconStartPaddingResource (int id)

Sets the start padding for this chip's icon using a resource id.

Related XML Attributes:

Parameters
id int: The resource id for the start padding of this chip's icon.

setMaxWidth

void setMaxWidth (int maxWidth)

Sets the width of the TextView to be exactly pixels wide.

Parameters
maxWidth int: maximum width of the textview.

setRippleColor

void setRippleColor (ColorStateList rippleColor)

Sets this chip's ripple color.

Related XML Attributes:

Parameters
rippleColor ColorStateList: This chip's ripple color.

setRippleColorResource

void setRippleColorResource (int id)

Sets this chip's ripple color using a resource id.

Related XML Attributes:

Parameters
id int: The resource id of this chip's ripple color.

setShowMotionSpec

void setShowMotionSpec (MotionSpec showMotionSpec)

Sets this chip's show motion spec.

Related XML Attributes:

Parameters
showMotionSpec MotionSpec: This chip's show motion spec.

setShowMotionSpecResource

void setShowMotionSpecResource (int id)

Sets this chip's show motion spec using a resource id.

Related XML Attributes:

Parameters
id int: The resource id of this chip's show motion spec.

setText

void setText (CharSequence text)

Parameters
text CharSequence

setTextAppearance

void setTextAppearance (TextAppearance textAppearance)

Parameters
textAppearance TextAppearance

setTextAppearanceResource

void setTextAppearanceResource (int id)

Parameters
id int

setTextEndPadding

void setTextEndPadding (float textEndPadding)

Sets the end padding for this chip's text.

Related XML Attributes:

Parameters
textEndPadding float: The end padding of this chip's text.

setTextEndPaddingResource

void setTextEndPaddingResource (int id)

Sets the end padding for this chip's text using a resource id.

Related XML Attributes:

Parameters
id int: The resource id for the end padding of this chip's text.

setTextResource

void setTextResource (int id)

Parameters
id int

setTextStartPadding

void setTextStartPadding (float textStartPadding)

Sets the start padding for this chip's text.

Related XML Attributes:

Parameters
textStartPadding float: The start padding of this chip's text.

setTextStartPaddingResource

void setTextStartPaddingResource (int id)

Sets the start padding for this chip's text using a resource id.

Related XML Attributes:

Parameters
id int: The resource id for the start padding of this chip's text.

setTintList

void setTintList (ColorStateList tint)

Parameters
tint ColorStateList

setTintMode

void setTintMode (PorterDuff.Mode tintMode)

Parameters
tintMode PorterDuff.Mode

setUseCompatRipple

void setUseCompatRipple (boolean useCompatRipple)

Sets whether this ChipDrawable should draw its own compatibility ripples.

Parameters
useCompatRipple boolean

setVisible

boolean setVisible (boolean visible, 
                boolean restart)

Parameters
visible boolean

restart boolean

Returns
boolean

unscheduleDrawable

void unscheduleDrawable (Drawable who, 
                Runnable what)

Parameters
who Drawable

what Runnable

Protected methods

onLevelChange

boolean onLevelChange (int level)

Parameters
level int

Returns
boolean

onSizeChange

void onSizeChange ()

Attempts to call onChipDrawableSizeChange() on the delegate.