Android 12 Developer Preview is here! Try it out, and give us your feedback!

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.
  • R.attr.ellipsize - Does not support TextUtils.TruncateAt.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: chipIcon, checkedIcon, and 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_checkedIconTint  
Chip_chipBackgroundColor  
Chip_chipCornerRadius  
Chip_chipEndPadding  
Chip_chipIconSize  
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

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

Returns the ColorStateList used to tint the 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()

Returns this chip's icon size.

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 setCheckedIconTint(ColorStateList checkedIconTint)

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

void setCheckedIconTintResource(int id)

Sets the checked icon's color tint 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. call ShapeAppearanceModel.withCornerSize(float) or call ShapeAppearanceModel.toBuilder() on the MaterialShapeDrawable.getShapeAppearanceModel(), modify the shape using the builder and then call MaterialShapeDrawable.setShapeAppearanceModel(ShapeAppearanceModel).

void setChipCornerRadiusResource(int id)

This method is deprecated. call ShapeAppearanceModel.withCornerSize(float) or call ShapeAppearanceModel.toBuilder() on the MaterialShapeDrawable.getShapeAppearanceModel(), modify the shape using the builder and then call MaterialShapeDrawable.setShapeAppearanceModel(ShapeAppearanceModel).

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)

Sets this chip icon's size.

void setChipIconSizeResource(int id)

Sets this chip icon's size using a resource 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 setTextSize(float size)
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 ChipDrawable.Delegate.onChipDrawableSizeChange() on the delegate.

Inherited methods

XML attributes

Chip_checkedIcon

Related methods:

Chip_checkedIconTint

Related methods:

Chip_chipBackgroundColor

Related methods:

Chip_chipCornerRadius

Related methods:

Chip_chipEndPadding

Related methods:

Chip_chipIconSize

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

public static 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

public static ChipDrawable createFromResource (Context context, 
                int id)

Returns a ChipDrawable from the given XML resource. All attributes from R.styleable.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

public void draw (Canvas canvas)

Parameters
canvas Canvas

getAlpha

public int getAlpha ()

Returns
int

getCheckedIcon

public Drawable getCheckedIcon ()

Returns this chip's checked icon.

Related XML Attributes:

Returns
Drawable

getCheckedIconTint

public ColorStateList getCheckedIconTint ()

Returns the ColorStateList used to tint the checked icon.

Returns
ColorStateList

getChipBackgroundColor

public ColorStateList getChipBackgroundColor ()

Returns this chip's background color.

Related XML Attributes:

Returns
ColorStateList

getChipCornerRadius

public float getChipCornerRadius ()

Returns this chip's corner radius.

Related XML Attributes:

Returns
float

getChipEndPadding

public float getChipEndPadding ()

Returns this chip's end padding.

Related XML Attributes:

Returns
float

getChipIcon

public Drawable getChipIcon ()

Returns
Drawable

getChipIconSize

public float getChipIconSize ()

Returns this chip's icon size. If a non-positive value is returned, the icon drawable's width and height (up to 24dp) will be used to measure its bounds intead.

Related XML Attributes:

Returns
float

getChipIconTint

public ColorStateList getChipIconTint ()

Returns the ColorStateList used to tint the chip icon.

Returns
ColorStateList

getChipMinHeight

public float getChipMinHeight ()

Returns this chip's minimum height.

Related XML Attributes:

Returns
float

getChipStartPadding

public float getChipStartPadding ()

Returns this chip's start padding.

Related XML Attributes:

Returns
float

getChipStrokeColor

public ColorStateList getChipStrokeColor ()

Returns this chip's stroke color.

Related XML Attributes:

Returns
ColorStateList

getChipStrokeWidth

public float getChipStrokeWidth ()

Returns this chip's stroke width.

Related XML Attributes:

Returns
float

getChipTouchBounds

public void getChipTouchBounds (RectF bounds)

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

Parameters
bounds RectF

getCloseIcon

public Drawable getCloseIcon ()

Returns
Drawable

getCloseIconContentDescription

public CharSequence getCloseIconContentDescription ()

Returns
CharSequence

getCloseIconEndPadding

public float getCloseIconEndPadding ()

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

Related XML Attributes:

Returns
float

getCloseIconSize

public float getCloseIconSize ()

Returns
float

getCloseIconStartPadding

public float getCloseIconStartPadding ()

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

Related XML Attributes:

Returns
float

getCloseIconState

public int[] getCloseIconState ()

Describes the current state of the close icon.

Returns
int[]

getCloseIconTint

public ColorStateList getCloseIconTint ()

Returns
ColorStateList

getCloseIconTouchBounds

public 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

public ColorFilter getColorFilter ()

Returns
ColorFilter

getEllipsize

public TextUtils.TruncateAt getEllipsize ()

Returns
TextUtils.TruncateAt

getHideMotionSpec

public MotionSpec getHideMotionSpec ()

Returns this chip's hide motion spec.

Related XML Attributes:

Returns
MotionSpec

getIconEndPadding

public float getIconEndPadding ()

Returns the end padding for this chip's icon.

Related XML Attributes:

Returns
float

getIconStartPadding

public float getIconStartPadding ()

Returns the start padding for this chip's icon.

Related XML Attributes:

Returns
float

getIntrinsicHeight

public int getIntrinsicHeight ()

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

Returns
int

getIntrinsicWidth

public int getIntrinsicWidth ()

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

Returns
int

getMaxWidth

public int getMaxWidth ()

Returns the maximum width of TextView in terms of pixels.

Returns
int

See also:

getOpacity

public int getOpacity ()

Returns
int

getOutline

public void getOutline (Outline outline)

Parameters
outline Outline

getRippleColor

public ColorStateList getRippleColor ()

Returns this chip's ripple color.

Related XML Attributes:

Returns
ColorStateList

getShowMotionSpec

public MotionSpec getShowMotionSpec ()

Returns this chip's show motion spec.

Related XML Attributes:

Returns
MotionSpec

getText

public CharSequence getText ()

Returns
CharSequence

getTextAppearance

public TextAppearance getTextAppearance ()

Returns
TextAppearance

getTextEndPadding

public float getTextEndPadding ()

Returns the end padding for this chip's text.

Related XML Attributes:

Returns
float

getTextStartPadding

public float getTextStartPadding ()

Returns the start padding for this chip's text.

Related XML Attributes:

Returns
float

getUseCompatRipple

public boolean getUseCompatRipple ()

Returns whether this ChipDrawable should draw its own compatibility ripples.

Returns
boolean

invalidateDrawable

public void invalidateDrawable (Drawable who)

Parameters
who Drawable

isCheckable

public boolean isCheckable ()

Returns
boolean

isCheckedIconEnabled

public boolean isCheckedIconEnabled ()

This method is deprecated.
Use isCheckedIconVisible() instead.

Returns
boolean

isCheckedIconVisible

public boolean isCheckedIconVisible ()

Returns
boolean

isChipIconEnabled

public boolean isChipIconEnabled ()

This method is deprecated.
Use isChipIconVisible() instead.

Returns
boolean

isChipIconVisible

public boolean isChipIconVisible ()

Returns
boolean

isCloseIconEnabled

public boolean isCloseIconEnabled ()

This method is deprecated.
Use isCloseIconVisible() instead.

Returns
boolean

isCloseIconStateful

public boolean isCloseIconStateful ()

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

Returns
boolean

isCloseIconVisible

public boolean isCloseIconVisible ()

Returns
boolean

isStateful

public boolean isStateful ()

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

Returns
boolean

onLayoutDirectionChanged

public boolean onLayoutDirectionChanged (int layoutDirection)

Parameters
layoutDirection int

Returns
boolean

onStateChange

public boolean onStateChange (int[] state)

Parameters
state int

Returns
boolean

onTextSizeChange

public void onTextSizeChange ()

scheduleDrawable

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

Parameters
who Drawable

what Runnable

when long

setAlpha

public void setAlpha (int alpha)

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

Parameters
alpha int

setCheckable

public void setCheckable (boolean checkable)

Parameters
checkable boolean

setCheckableResource

public void setCheckableResource (int id)

Parameters
id int

setCheckedIcon

public void setCheckedIcon (Drawable checkedIcon)

Sets this chip's checked icon.

Related XML Attributes:

Parameters
checkedIcon Drawable: This chip's checked icon.

setCheckedIconEnabled

public void setCheckedIconEnabled (boolean checkedIconEnabled)

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

Parameters
checkedIconEnabled boolean

setCheckedIconEnabledResource

public void setCheckedIconEnabledResource (int id)

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

Parameters
id int

setCheckedIconResource

public 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.

setCheckedIconTint

public void setCheckedIconTint (ColorStateList checkedIconTint)

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

Related XML Attributes:

Parameters
checkedIconTint ColorStateList: ColorStateList to tint the checked icon.

setCheckedIconTintResource

public void setCheckedIconTintResource (int id)

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

Related XML Attributes:

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

setCheckedIconVisible

public void setCheckedIconVisible (int id)

Parameters
id int

setCheckedIconVisible

public void setCheckedIconVisible (boolean checkedIconVisible)

Parameters
checkedIconVisible boolean

setChipBackgroundColor

public void setChipBackgroundColor (ColorStateList chipBackgroundColor)

Sets this chip's background color.

Related XML Attributes:

Parameters
chipBackgroundColor ColorStateList: This chip's background color.

setChipBackgroundColorResource

public 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

public void setChipCornerRadius (float chipCornerRadius)

This method is deprecated.
call ShapeAppearanceModel.withCornerSize(float) or call ShapeAppearanceModel.toBuilder() on the MaterialShapeDrawable.getShapeAppearanceModel(), modify the shape using the builder and then call MaterialShapeDrawable.setShapeAppearanceModel(ShapeAppearanceModel).

Parameters
chipCornerRadius float

setChipCornerRadiusResource

public void setChipCornerRadiusResource (int id)

This method is deprecated.
call ShapeAppearanceModel.withCornerSize(float) or call ShapeAppearanceModel.toBuilder() on the MaterialShapeDrawable.getShapeAppearanceModel(), modify the shape using the builder and then call MaterialShapeDrawable.setShapeAppearanceModel(ShapeAppearanceModel).

Parameters
id int

setChipEndPadding

public void setChipEndPadding (float chipEndPadding)

Sets this chip's end padding.

Related XML Attributes:

Parameters
chipEndPadding float: This chip's end padding.

setChipEndPaddingResource

public 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

public void setChipIcon (Drawable chipIcon)

Parameters
chipIcon Drawable

setChipIconEnabled

public void setChipIconEnabled (boolean chipIconEnabled)

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

Parameters
chipIconEnabled boolean

setChipIconEnabledResource

public void setChipIconEnabledResource (int id)

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

Parameters
id int

setChipIconResource

public void setChipIconResource (int id)

Parameters
id int

setChipIconSize

public void setChipIconSize (float chipIconSize)

Sets this chip icon's size. If the value is zero or negative, the icon drawable's width and height (up to 24dp) will be used instead.

Related XML Attributes:

Parameters
chipIconSize float: This chip's icon size.

setChipIconSizeResource

public void setChipIconSizeResource (int id)

Sets this chip icon's size using a resource id. If the value is zero (@null) or negative, the icon drawable's width and height (up to 24dp) will be used instead.

Related XML Attributes:

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

setChipIconTint

public 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

public 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

public void setChipIconVisible (int id)

Parameters
id int

setChipIconVisible

public void setChipIconVisible (boolean chipIconVisible)

Parameters
chipIconVisible boolean

setChipMinHeight

public void setChipMinHeight (float chipMinHeight)

Sets this chip's minimum height.

Related XML Attributes:

Parameters
chipMinHeight float: This chip's mininum height.

setChipMinHeightResource

public 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

public void setChipStartPadding (float chipStartPadding)

Sets this chip's start padding.

Related XML Attributes:

Parameters
chipStartPadding float: This chip's start padding.

setChipStartPaddingResource

public 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

public void setChipStrokeColor (ColorStateList chipStrokeColor)

Sets this chip's stroke color.

Related XML Attributes:

Parameters
chipStrokeColor ColorStateList: This chip's stroke color.

setChipStrokeColorResource

public 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

public void setChipStrokeWidth (float chipStrokeWidth)

Sets this chip's stroke width.

Related XML Attributes:

Parameters
chipStrokeWidth float: This chip's stroke width.

setChipStrokeWidthResource

public 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

public void setCloseIcon (Drawable closeIcon)

Parameters
closeIcon Drawable

setCloseIconContentDescription

public void setCloseIconContentDescription (CharSequence closeIconContentDescription)

Parameters
closeIconContentDescription CharSequence

setCloseIconEnabled

public void setCloseIconEnabled (boolean closeIconEnabled)

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

Parameters
closeIconEnabled boolean

setCloseIconEnabledResource

public void setCloseIconEnabledResource (int id)

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

Parameters
id int

setCloseIconEndPadding

public 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

public 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

public void setCloseIconResource (int id)

Parameters
id int

setCloseIconSize

public void setCloseIconSize (float closeIconSize)

Parameters
closeIconSize float

setCloseIconSizeResource

public void setCloseIconSizeResource (int id)

Parameters
id int

setCloseIconStartPadding

public 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

public 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

public 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

public void setCloseIconTint (ColorStateList closeIconTint)

Parameters
closeIconTint ColorStateList

setCloseIconTintResource

public void setCloseIconTintResource (int id)

Parameters
id int

setCloseIconVisible

public void setCloseIconVisible (boolean closeIconVisible)

Parameters
closeIconVisible boolean

setCloseIconVisible

public void setCloseIconVisible (int id)

Parameters
id int

setColorFilter

public void setColorFilter (ColorFilter colorFilter)

Parameters
colorFilter ColorFilter

setDelegate

public void setDelegate (ChipDrawable.Delegate delegate)

Sets the View delegate that owns this ChipDrawable.

Parameters
delegate ChipDrawable.Delegate

setEllipsize

public void setEllipsize (TextUtils.TruncateAt truncateAt)

Parameters
truncateAt TextUtils.TruncateAt

setHideMotionSpec

public void setHideMotionSpec (MotionSpec hideMotionSpec)

Sets this chip's hide motion spec.

Related XML Attributes:

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

setHideMotionSpecResource

public 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

public 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

public 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

public 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

public 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

public void setMaxWidth (int maxWidth)

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

Parameters
maxWidth int: maximum width of the textview.

setRippleColor

public void setRippleColor (ColorStateList rippleColor)

Sets this chip's ripple color.

Related XML Attributes:

Parameters
rippleColor ColorStateList: This chip's ripple color.

setRippleColorResource

public 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

public void setShowMotionSpec (MotionSpec showMotionSpec)

Sets this chip's show motion spec.

Related XML Attributes:

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

setShowMotionSpecResource

public 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

public void setText (CharSequence text)

Parameters
text CharSequence

setTextAppearance

public void setTextAppearance (TextAppearance textAppearance)

Parameters
textAppearance TextAppearance

setTextAppearanceResource

public void setTextAppearanceResource (int id)

Parameters
id int

setTextEndPadding

public 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

public 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

public void setTextResource (int id)

Parameters
id int

setTextSize

public void setTextSize (float size)

Parameters
size float

setTextStartPadding

public 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

public 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

public void setTintList (ColorStateList tint)

Parameters
tint ColorStateList

setTintMode

public void setTintMode (PorterDuff.Mode tintMode)

Parameters
tintMode PorterDuff.Mode

setUseCompatRipple

public void setUseCompatRipple (boolean useCompatRipple)

Sets whether this ChipDrawable should draw its own compatibility ripples.

Parameters
useCompatRipple boolean

setVisible

public boolean setVisible (boolean visible, 
                boolean restart)

Parameters
visible boolean

restart boolean

Returns
boolean

unscheduleDrawable

public void unscheduleDrawable (Drawable who, 
                Runnable what)

Parameters
who Drawable

what Runnable

Protected methods

onLevelChange

protected boolean onLevelChange (int level)

Parameters
level int

Returns
boolean

onSizeChange

protected void onSizeChange ()

Attempts to call ChipDrawable.Delegate.onChipDrawableSizeChange() on the delegate.