ChipDrawable

public class ChipDrawable extends MaterialShapeDrawable


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

  • setBounds, taking into account getIntrinsicHeight and getIntrinsicWidth.
  • draw
  • setCallback, to support invalidations on the chip drawable or any of its child drawables. This includes animations.
  • setState, to support checking the chip, and touch/mouse/keyboard interactions on the chip.
  • setCloseIconState, to support touch, mouse, or keyboard interactions on the close icon.
  • setHotspot
  • setLayoutDirection, to support RTL mode.

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.

For more information, see the component developer guidance and design guidelines.

See also
Chip

Summary

Nested types

public interface ChipDrawable.Delegate

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

Public fields

int
Drawable
ColorStateList
ColorStateList
float
float

Padding at the end of the chip, after the close icon.

Drawable
float
ColorStateList
float
float

Padding at the start of the chip, before the icon.

ColorStateList
float
Drawable
CharSequence
float

Padding at the end of the close icon, before the end of the chip.

float
float

Padding at the start of the close icon, after the text.

ColorStateList
ColorFilter
MotionSpec
float

Padding at the end of the icon, before the text.

float

Padding at the start of the icon, after the start of the chip.

int
ColorStateList
MotionSpec
CharSequence
float

Padding at the end of the text, before the close icon.

float

Padding at the start of the text, after the icon.

boolean

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
Drawable

Returns this chip's checked icon.

ColorStateList

Returns the android.content.res.ColorStateList used to tint the checked icon.

ColorStateList

Returns this chip's background color.

float

Returns this chip's corner radius.

float

Returns this chip's end padding.

Drawable
float

Returns this chip's icon size.

ColorStateList

Returns the android.content.res.ColorStateList used to tint the chip icon.

float

Returns this chip's minimum height.

float

Returns this chip's start padding.

ColorStateList

Returns this chip's stroke color.

float

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
CharSequence
float

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

float
float

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

int[]

Describes the current state of the close icon.

ColorStateList
void

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

ColorFilter
TruncateAt
MotionSpec

Returns this chip's hide motion spec.

float

Returns the end padding for this chip's icon.

float

Returns the start padding for this chip's icon.

int

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

int

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

int

Returns the maximum width of TextView in terms of pixels.

int
void
getOutline(Outline outline)
ColorStateList

Returns this chip's ripple color.

MotionSpec

Returns this chip's show motion spec.

abstract int[]
CharSequence
TextAppearance
float

Returns the end padding for this chip's text.

float

Returns the start padding for this chip's text.

boolean

Returns whether this ChipDrawable should draw its own compatibility ripples.

void
invalidateDrawable(Drawable who)
boolean
boolean

This method is deprecated.

Use isCheckedIconVisible instead.

boolean
boolean

This method is deprecated.

Use isChipIconVisible instead.

boolean
boolean

This method is deprecated.

Use isCloseIconVisible instead.

boolean

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

boolean
boolean

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

boolean
onLayoutDirectionChanged(int layoutDirection)
boolean
onStateChange(int[] state)
void

Handles a change in the text's size.

void
scheduleDrawable(Drawable who, Runnable what, long when)
void
setAlpha(int alpha)

Sets the alpha of this ChipDrawable.

void
setCheckable(boolean checkable)
void
void
setCheckedIcon(Drawable checkedIcon)

Sets this chip's checked icon.

void
setCheckedIconEnabled(boolean checkedIconEnabled)

This method is deprecated.

Use setCheckedIconVisible instead.

void

This method is deprecated.

Use setCheckedIconVisible instead.

void

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

void
setCheckedIconTint(ColorStateList checkedIconTint)

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

void

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

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

Sets this chip's background color.

void

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

void
setChipCornerRadius(float chipCornerRadius)

This method is deprecated.

call withCornerSize or call toBuilder on the getShapeAppearanceModel, modify the shape using the builder and then call setShapeAppearanceModel.

void

This method is deprecated.

call withCornerSize or call toBuilder on the getShapeAppearanceModel, modify the shape using the builder and then call setShapeAppearanceModel.

void
setChipEndPadding(float chipEndPadding)

Sets this chip's end padding.

void

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

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

This method is deprecated.

Use setChipIconVisible instead.

void

This method is deprecated.

Use setChipIconVisible instead.

void
void
setChipIconSize(float chipIconSize)

Sets this chip icon's size.

void

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

void
setChipIconTint(ColorStateList chipIconTint)

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

void

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

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

Sets this chip's minimum height.

void

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

void
setChipStartPadding(float chipStartPadding)

Sets this chip's start padding.

void

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

void
setChipStrokeColor(ColorStateList chipStrokeColor)

Sets this chip's stroke color.

void

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

void
setChipStrokeWidth(float chipStrokeWidth)

Sets this chip's stroke width.

void

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

void

This method is deprecated.

Use setCloseIconVisible instead.

void
setCloseIconEndPadding(float closeIconEndPadding)

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

void

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

void
void
setCloseIconSize(float closeIconSize)
void
void
setCloseIconStartPadding(float closeIconStartPadding)

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

void

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
void
setCloseIconVisible(boolean closeIconVisible)
void
void
setColorFilter(ColorFilter colorFilter)
void

Sets the View delegate that owns this ChipDrawable.

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

Sets this chip's hide motion spec.

void

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

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

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

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

void
setShowMotionSpec(MotionSpec showMotionSpec)

Sets this chip's show motion spec.

void

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

void
void
void
void
setTextColor(ColorStateList color)
void
setTextColor(int color)
void
setTextEndPadding(float textEndPadding)

Sets the end padding for this chip's text.

void

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

void
void
setTextSize(float size)
void
setTextStartPadding(float textStartPadding)

Sets the start padding for this chip's text.

void

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

void
setTintList(ColorStateList tint)
void
setTintMode(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

Attempts to call onChipDrawableSizeChange on the delegate.

Inherited Constants

From com.google.android.material.shape.MaterialShapeDrawable
static final int

Always draw fake shadows, never draw native elevation shadows.

static final int

Try to draw native elevation shadows if possible, otherwise use fake shadows.

static final int

Never draw fake shadows.

Inherited methods

From com.google.android.material.shape.MaterialShapeDrawable
int
compositeElevationOverlayIfNeeded(int backgroundColor)
static MaterialShapeDrawable
createWithElevationOverlay(Context context)

Returns a MaterialShapeDrawable with the elevation overlay functionality initialized, a fill color of colorSurface, and an elevation of 0.

static MaterialShapeDrawable
createWithElevationOverlay(Context context, float elevation)

Returns a MaterialShapeDrawable with the elevation overlay functionality initialized, a fill color of colorSurface, and an elevation of elevation.

static MaterialShapeDrawable
createWithElevationOverlay(
    Context context,
    float elevation,
    ColorStateList backgroundTint
)

Returns a MaterialShapeDrawable with the elevation overlay functionality initialized, a fill color of backgroundTint, and an elevation of elevation.

float

Returns the actual size of the bottom left corner for the current bounds.

float

Returns the actual size of the bottom right corner for the current bounds.

RectF
ConstantState
float

Returns the elevation used to render both fake shadows when requiresCompatShadow is true and elevation overlays.

ColorStateList

Get the color used for the fill.

float

Get the interpolation of the path, between 0 and 1.

boolean
getPadding(Rect padding)
Style

Get the current style used by the shape's paint.

float

Returns the parent absolute elevation.

void
getPathForSize(int width, int height, Path path)

This method is deprecated.

see ShapeAppearancePathProvider

int

Get the tint color factoring in any other runtime modifications such as elevation overlays.

float

Get the scale of the rendered path.

int

Returns the rotation offset applied to the fake shadow which is drawn when requiresCompatShadow is true.

int
int

This method is deprecated.

use getElevation instead.

int

Returns the X offset of the shadow from the bounds of the shape.

int

Returns the Y offset of the shadow from the bounds of the shape.

int

Get the shadow radius rendered by the path in pixels.

ShapeAppearanceModel

Get the ShapeAppearanceModel containing the path that will be rendered in this drawable.

ShapePathModel

This method is deprecated.

Use getShapeAppearanceModel instead.

ColorStateList

Get the color used for the stroke.

ColorStateList

Get the stroke's current ColorStateList.

float

Get the stroke width used by the shape's paint.

ColorStateList

Get the tint list used by the shape's paint.

float

Returns the actual size of the top left corner for the current bounds.

float

Returns the actual size of the top right corner for the current bounds.

float

Returns the translationZ used to render both fake shadows when requiresCompatShadow is true and elevation overlays.

Region
float

Returns the visual z position of this drawable, in pixels.

void
initializeElevationOverlay(Context context)

Initializes the elevation overlay functionality for this drawable.

void
boolean

Returns whether the elevation overlay functionality is initialized and enabled in this drawable's theme context.

boolean

Returns whether the elevation overlay functionality has been initialized for this drawable.

boolean

Determines whether a point is contained within the transparent region of the Drawable.

boolean

This method is deprecated.

use getShadowCompatibilityMode instead

Drawable
void
onBoundsChange(Rect bounds)
boolean

Returns true if compat shadows should be drawn.

void
setAlpha(int alpha)
void

Updates the corners for the given CornerSize.

void
setCornerSize(float cornerSize)

Updates the corners for the given CornerSize.

void
void
setElevation(float elevation)

Sets the elevation used to render both fake shadows when requiresCompatShadow is true and elevation overlays.

void
setFillColor(ColorStateList fillColor)

Set the color used for the fill.

void
setInterpolation(float interpolation)

Set the interpolation of the path, between 0 and 1.

void
setPadding(int left, int top, int right, int bottom)

Configure the padding of the shape

void
setPaintStyle(Style paintStyle)

Set the style used by the shape's paint.

void
setParentAbsoluteElevation(float parentAbsoluteElevation)

Sets the parent absolute elevation, which is used to render elevation overlays.

void
setScale(float scale)

Set the scale of the rendered path.

void
void
setShadowColor(int shadowColor)

Set the color of fake shadow rendered behind the shape.

void
setShadowCompatRotation(int shadowRotation)

Set the rotation offset applied to the fake shadow which is drawn when requiresCompatShadow is true.

void

Set the shadow compatibility mode.

void
setShadowElevation(int shadowElevation)

This method is deprecated.

use setElevation instead.

void
setShadowEnabled(boolean shadowEnabled)

This method is deprecated.

use setShadowCompatibilityMode instead.

void
setShadowRadius(int shadowRadius)

This method is deprecated.

use setElevation instead.

void

Set the ShapeAppearanceModel containing the path that will be rendered in this drawable.

void

This method is deprecated.

Use setShapeAppearanceModel instead.

void
setStroke(float strokeWidth, ColorStateList strokeColor)

Set the shape's stroke width and stroke color using a ColorStateList.

void
setStroke(float strokeWidth, int strokeColor)

Set the shape's stroke width and stroke color.

void
setStrokeColor(ColorStateList strokeColor)

Set the color used for the stroke.

void
setStrokeTint(int tintColor)

Set the shape's stroke color.

void
setStrokeTint(ColorStateList tintList)

Set the shape's stroke ColorStateList

void
setStrokeWidth(float strokeWidth)

Set the stroke width used by the shape's paint.

void
setTint(int tintColor)
void
setTranslationZ(float translationZ)

Sets the translationZ used to render both fake shadows when requiresCompatShadow is true and elevation overlays.

void
setUseTintColorForShadow(boolean useTintColorForShadow)

Set whether fake shadow color should match next set tint color.

void
setZ(float z)

Sets the visual z position of this view, in pixels.

Public fields

alpha

public int alpha

checkedIcon

public Drawable checkedIcon

checkedIconTint

public ColorStateList checkedIconTint

chipBackgroundColor

public ColorStateList chipBackgroundColor

chipCornerRadius

public float chipCornerRadius

chipEndPadding

public float chipEndPadding

Padding at the end of the chip, after the close icon.

chipIcon

public Drawable chipIcon

chipIconSize

public float chipIconSize

chipIconTint

public ColorStateList chipIconTint

chipMinHeight

public float chipMinHeight

chipStartPadding

public float chipStartPadding

Padding at the start of the chip, before the icon.

chipStrokeColor

public ColorStateList chipStrokeColor

chipStrokeWidth

public float chipStrokeWidth

closeIcon

public Drawable closeIcon

closeIconContentDescription

public CharSequence closeIconContentDescription

closeIconEndPadding

public float closeIconEndPadding

Padding at the end of the close icon, before the end of the chip. If close icon exists.

closeIconSize

public float closeIconSize

closeIconStartPadding

public float closeIconStartPadding

Padding at the start of the close icon, after the text. If close icon exists.

closeIconTint

public ColorStateList closeIconTint

colorFilter

public ColorFilter colorFilter

hideMotionSpec

public MotionSpec hideMotionSpec

iconEndPadding

public float iconEndPadding

Padding at the end of the icon, before the text. If icon exists.

iconStartPadding

public float iconStartPadding

Padding at the start of the icon, after the start of the chip. If icon exists.

maxWidth

public int maxWidth

rippleColor

public ColorStateList rippleColor

showMotionSpec

public MotionSpec showMotionSpec

text

public CharSequence text

textEndPadding

public float textEndPadding

Padding at the end of the text, before the close icon.

textStartPadding

public float textStartPadding

Padding at the start of the text, after the icon.

useCompatRipple

public boolean useCompatRipple

Public methods

createFromAttributes

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

Returns a ChipDrawable from the given attributes.

createFromResource

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

draw

public void draw(Canvas canvas)

getAlpha

public int getAlpha()

getCheckedIcon

public Drawable getCheckedIcon()

Returns this chip's checked icon.

ref com.google.android.material.R.styleable#Chip_checkedIcon

See also
setCheckedIcon

getCheckedIconTint

public ColorStateList getCheckedIconTint()

Returns the android.content.res.ColorStateList used to tint the checked icon.

getChipBackgroundColor

public ColorStateList getChipBackgroundColor()

Returns this chip's background color.

ref com.google.android.material.R.styleable#Chip_chipBackgroundColor

getChipCornerRadius

public float getChipCornerRadius()

Returns this chip's corner radius.

ref com.google.android.material.R.styleable#Chip_chipCornerRadius

getChipEndPadding

public float getChipEndPadding()

Returns this chip's end padding.

ref com.google.android.material.R.styleable#Chip_chipEndPadding

getChipIcon

public Drawable getChipIcon()

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

ref com.google.android.material.R.styleable#Chip_chipIconTint

See also
setChipIconSize

getChipIconTint

public ColorStateList getChipIconTint()

Returns the android.content.res.ColorStateList used to tint the chip icon.

getChipMinHeight

public float getChipMinHeight()

Returns this chip's minimum height.

ref com.google.android.material.R.styleable#Chip_chipMinHeight

See also
setChipMinHeight

getChipStartPadding

public float getChipStartPadding()

Returns this chip's start padding.

ref com.google.android.material.R.styleable#Chip_chipStartPadding

getChipStrokeColor

public ColorStateList getChipStrokeColor()

Returns this chip's stroke color.

ref com.google.android.material.R.styleable#Chip_chipStrokeColor

getChipStrokeWidth

public float getChipStrokeWidth()

Returns this chip's stroke width.

ref com.google.android.material.R.styleable#Chip_chipStrokeWidth

getChipTouchBounds

public void getChipTouchBounds(RectF bounds)

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

getCloseIcon

public Drawable getCloseIcon()

getCloseIconContentDescription

public CharSequence getCloseIconContentDescription()

getCloseIconEndPadding

public float getCloseIconEndPadding()

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

ref com.google.android.material.R.styleable#Chip_closeIconEndPadding

getCloseIconSize

public float getCloseIconSize()

getCloseIconStartPadding

public float getCloseIconStartPadding()

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

ref com.google.android.material.R.styleable#Chip_closeIconStartPadding

getCloseIconState

public int[] getCloseIconState()

Describes the current state of the close icon.

getCloseIconTint

public ColorStateList getCloseIconTint()

getCloseIconTouchBounds

public void getCloseIconTouchBounds(RectF bounds)

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

getColorFilter

public ColorFilter getColorFilter()

getEllipsize

public TruncateAt getEllipsize()

getHideMotionSpec

public MotionSpec getHideMotionSpec()

Returns this chip's hide motion spec.

ref com.google.android.material.R.styleable#Chip_hideMotionSpec

getIconEndPadding

public float getIconEndPadding()

Returns the end padding for this chip's icon.

ref com.google.android.material.R.styleable#Chip_iconEndPadding

getIconStartPadding

public float getIconStartPadding()

Returns the start padding for this chip's icon.

ref com.google.android.material.R.styleable#Chip_iconStartPadding

getIntrinsicHeight

public int getIntrinsicHeight()

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

getIntrinsicWidth

public int getIntrinsicWidth()

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

getMaxWidth

public int getMaxWidth()

Returns the maximum width of TextView in terms of pixels.

See also
setMaxWidth

getOpacity

public int getOpacity()

getOutline

public void getOutline(Outline outline)

getRippleColor

public ColorStateList getRippleColor()

Returns this chip's ripple color.

ref com.google.android.material.R.styleable#Chip_rippleColor

See also
setRippleColor

getShowMotionSpec

public MotionSpec getShowMotionSpec()

Returns this chip's show motion spec.

ref com.google.android.material.R.styleable#Chip_showMotionSpec

getState

public abstract int[] getState()

getText

public CharSequence getText()

getTextAppearance

public TextAppearance getTextAppearance()

getTextEndPadding

public float getTextEndPadding()

Returns the end padding for this chip's text.

ref com.google.android.material.R.styleable#Chip_textEndPadding

getTextStartPadding

public float getTextStartPadding()

Returns the start padding for this chip's text.

ref com.google.android.material.R.styleable#Chip_textStartPadding

getUseCompatRipple

public boolean getUseCompatRipple()

Returns whether this ChipDrawable should draw its own compatibility ripples.

invalidateDrawable

public void invalidateDrawable(Drawable who)

isCheckable

public boolean isCheckable()

isCheckedIconEnabled

public boolean isCheckedIconEnabled()

isCheckedIconVisible

public boolean isCheckedIconVisible()

isChipIconEnabled

public boolean isChipIconEnabled()

isChipIconVisible

public boolean isChipIconVisible()

isCloseIconEnabled

public boolean isCloseIconEnabled()

isCloseIconStateful

public boolean isCloseIconStateful()

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

isCloseIconVisible

public boolean isCloseIconVisible()

isStateful

public boolean isStateful()

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

onLayoutDirectionChanged

public boolean onLayoutDirectionChanged(int layoutDirection)

onStateChange

public boolean onStateChange(int[] state)

onTextSizeChange

public void onTextSizeChange()

Handles a change in the text's size.

scheduleDrawable

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

setAlpha

public void setAlpha(int alpha)

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

setCheckable

public void setCheckable(boolean checkable)

setCheckableResource

public void setCheckableResource(int id)

setCheckedIcon

public void setCheckedIcon(Drawable checkedIcon)

Sets this chip's checked icon.

ref com.google.android.material.R.styleable#Chip_checkedIcon

Parameters
Drawable checkedIcon

This chip's checked icon.

setCheckedIconEnabled

public void setCheckedIconEnabled(boolean checkedIconEnabled)

setCheckedIconEnabledResource

public void setCheckedIconEnabledResource(int id)

setCheckedIconResource

public void setCheckedIconResource(int id)

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

ref com.google.android.material.R.styleable#Chip_checkedIcon

Parameters
int id

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 .

ref com.google.android.material.R.styleable#Chip_checkedIconTint

Parameters
ColorStateList checkedIconTint

ColorStateList to tint the checked icon.

setCheckedIconTintResource

public void setCheckedIconTintResource(int id)

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

ref com.google.android.material.R.styleable#Chip_checkedIconTint

Parameters
int id

Resource id of a android.content.res.ColorStateList to tint the checked icon.

setCheckedIconVisible

public void setCheckedIconVisible(boolean checkedIconVisible)

setCheckedIconVisible

public void setCheckedIconVisible(int id)

setChipBackgroundColor

public void setChipBackgroundColor(ColorStateList chipBackgroundColor)

Sets this chip's background color.

ref com.google.android.material.R.styleable#Chip_chipBackgroundColor

Parameters
ColorStateList chipBackgroundColor

This chip's background color.

setChipBackgroundColorResource

public void setChipBackgroundColorResource(int id)

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

ref com.google.android.material.R.styleable#Chip_chipBackgroundColor

Parameters
int id

The resource id of this chip's background color.

setChipCornerRadius

public void setChipCornerRadius(float chipCornerRadius)

setChipCornerRadiusResource

public void setChipCornerRadiusResource(int id)

setChipEndPadding

public void setChipEndPadding(float chipEndPadding)

Sets this chip's end padding.

ref com.google.android.material.R.styleable#Chip_chipEndPadding

Parameters
float chipEndPadding

This chip's end padding.

setChipEndPaddingResource

public void setChipEndPaddingResource(int id)

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

ref com.google.android.material.R.styleable#Chip_chipEndPadding

Parameters
int id

The resource id for this chip's end padding.

setChipIcon

public void setChipIcon(Drawable chipIcon)

setChipIconEnabled

public void setChipIconEnabled(boolean chipIconEnabled)

setChipIconEnabledResource

public void setChipIconEnabledResource(int id)

setChipIconResource

public void setChipIconResource(int id)

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.

ref com.google.android.material.R.styleable#Chip_chipIconSize

Parameters
float chipIconSize

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.

ref com.google.android.material.R.styleable#Chip_chipIconSize

Parameters
int id

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 android.content.res.ColorStateList.

ref com.google.android.material.R.styleable#Chip_chipIconTint

Parameters
ColorStateList chipIconTint

ColorStateList to tint the chip icon.

setChipIconTintResource

public void setChipIconTintResource(int id)

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

ref com.google.android.material.R.styleable#Chip_chipIconTint

Parameters
int id

Resource id of a android.content.res.ColorStateList to tint the chip icon.

setChipIconVisible

public void setChipIconVisible(boolean chipIconVisible)

setChipIconVisible

public void setChipIconVisible(int id)

setChipMinHeight

public void setChipMinHeight(float chipMinHeight)

Sets this chip's minimum height.

ref com.google.android.material.R.styleable#Chip_chipMinHeight

Parameters
float chipMinHeight

This chip's minimum height.

setChipMinHeightResource

public void setChipMinHeightResource(int id)

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

ref com.google.android.material.R.styleable#Chip_chipMinHeight

Parameters
int id

The resource id of this chip's minimum height.

setChipStartPadding

public void setChipStartPadding(float chipStartPadding)

Sets this chip's start padding.

ref com.google.android.material.R.styleable#Chip_chipStartPadding

Parameters
float chipStartPadding

This chip's start padding.

setChipStartPaddingResource

public void setChipStartPaddingResource(int id)

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

ref com.google.android.material.R.styleable#Chip_chipStartPadding

Parameters
int id

The resource id of this chip's start padding.

setChipStrokeColor

public void setChipStrokeColor(ColorStateList chipStrokeColor)

Sets this chip's stroke color.

ref com.google.android.material.R.styleable#Chip_chipStrokeColor

Parameters
ColorStateList chipStrokeColor

This chip's stroke color.

setChipStrokeColorResource

public void setChipStrokeColorResource(int id)

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

ref com.google.android.material.R.styleable#Chip_chipStrokeColor

Parameters
int id

The resource id of this chip's stroke color.

setChipStrokeWidth

public void setChipStrokeWidth(float chipStrokeWidth)

Sets this chip's stroke width.

ref com.google.android.material.R.styleable#Chip_chipStrokeWidth

Parameters
float chipStrokeWidth

This chip's stroke width.

setChipStrokeWidthResource

public void setChipStrokeWidthResource(int id)

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

ref com.google.android.material.R.styleable#Chip_chipStrokeWidth

Parameters
int id

The resource id of this chip's stroke width.

setCloseIcon

public void setCloseIcon(Drawable closeIcon)

setCloseIconContentDescription

public void setCloseIconContentDescription(
    CharSequence closeIconContentDescription
)

setCloseIconEnabled

public void setCloseIconEnabled(boolean closeIconEnabled)

setCloseIconEnabledResource

public void setCloseIconEnabledResource(int id)

setCloseIconEndPadding

public void setCloseIconEndPadding(float closeIconEndPadding)

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

ref com.google.android.material.R.styleable#Chip_closeIconEndPadding

Parameters
float closeIconEndPadding

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.

ref com.google.android.material.R.styleable#Chip_closeIconEndPadding

Parameters
int id

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

setCloseIconResource

public void setCloseIconResource(int id)

setCloseIconSize

public void setCloseIconSize(float closeIconSize)

setCloseIconSizeResource

public void setCloseIconSizeResource(int id)

setCloseIconStartPadding

public void setCloseIconStartPadding(float closeIconStartPadding)

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

ref com.google.android.material.R.styleable#Chip_closeIconStartPadding

Parameters
float closeIconStartPadding

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.

ref com.google.android.material.R.styleable#Chip_closeIconStartPadding

Parameters
int id

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.

setCloseIconTint

public void setCloseIconTint(ColorStateList closeIconTint)

setCloseIconTintResource

public void setCloseIconTintResource(int id)

setCloseIconVisible

public void setCloseIconVisible(boolean closeIconVisible)

setCloseIconVisible

public void setCloseIconVisible(int id)

setColorFilter

public void setColorFilter(ColorFilter colorFilter)

setDelegate

public void setDelegate(ChipDrawable.Delegate delegate)

Sets the View delegate that owns this ChipDrawable.

setEllipsize

public void setEllipsize(TruncateAt truncateAt)

setHideMotionSpec

public void setHideMotionSpec(MotionSpec hideMotionSpec)

Sets this chip's hide motion spec.

ref com.google.android.material.R.styleable#Chip_hideMotionSpec

Parameters
MotionSpec hideMotionSpec

This chip's hide motion spec.

setHideMotionSpecResource

public void setHideMotionSpecResource(int id)

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

ref com.google.android.material.R.styleable#Chip_hideMotionSpec

Parameters
int id

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.

ref com.google.android.material.R.styleable#Chip_iconEndPadding

Parameters
float iconEndPadding

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.

ref com.google.android.material.R.styleable#Chip_iconEndPadding

Parameters
int id

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.

ref com.google.android.material.R.styleable#Chip_iconStartPadding

Parameters
float iconStartPadding

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.

ref com.google.android.material.R.styleable#Chip_iconStartPadding

Parameters
int id

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
int maxWidth

maximum width of the textview.

setRippleColor

public void setRippleColor(ColorStateList rippleColor)

Sets this chip's ripple color.

ref com.google.android.material.R.styleable#Chip_rippleColor

Parameters
ColorStateList rippleColor

This chip's ripple color.

setRippleColorResource

public void setRippleColorResource(int id)

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

ref com.google.android.material.R.styleable#Chip_rippleColor

Parameters
int id

The resource id of this chip's ripple color.

setShowMotionSpec

public void setShowMotionSpec(MotionSpec showMotionSpec)

Sets this chip's show motion spec.

ref com.google.android.material.R.styleable#Chip_showMotionSpec

Parameters
MotionSpec showMotionSpec

This chip's show motion spec.

setShowMotionSpecResource

public void setShowMotionSpecResource(int id)

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

ref com.google.android.material.R.styleable#Chip_showMotionSpec

Parameters
int id

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

setText

public void setText(CharSequence text)

setTextAppearance

public void setTextAppearance(TextAppearance textAppearance)

setTextAppearanceResource

public void setTextAppearanceResource(int id)

setTextColor

public void setTextColor(ColorStateList color)

setTextColor

public void setTextColor(int color)

setTextEndPadding

public void setTextEndPadding(float textEndPadding)

Sets the end padding for this chip's text.

ref com.google.android.material.R.styleable#Chip_textStartPadding

Parameters
float textEndPadding

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.

ref com.google.android.material.R.styleable#Chip_textEndPadding

Parameters
int id

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

setTextResource

public void setTextResource(int id)

setTextSize

public void setTextSize(float size)

setTextStartPadding

public void setTextStartPadding(float textStartPadding)

Sets the start padding for this chip's text.

ref com.google.android.material.R.styleable#Chip_textStartPadding

Parameters
float textStartPadding

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.

ref com.google.android.material.R.styleable#Chip_textStartPadding

Parameters
int id

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

setTintList

public void setTintList(ColorStateList tint)

setTintMode

public void setTintMode(Mode tintMode)

setUseCompatRipple

public void setUseCompatRipple(boolean useCompatRipple)

Sets whether this ChipDrawable should draw its own compatibility ripples.

setVisible

public boolean setVisible(boolean visible, boolean restart)

unscheduleDrawable

public void unscheduleDrawable(Drawable who, Runnable what)

Protected methods

onLevelChange

protected boolean onLevelChange(int level)

onSizeChange

protected void onSizeChange()

Attempts to call onChipDrawableSizeChange on the delegate.