Chip

public class Chip
extends AppCompatCheckBox implements ChipDrawable.Delegate, Shapeable, Checkable

java.lang.Object
   ↳ android.view.View
     ↳ android.widget.TextView
       ↳ android.widget.Button
         ↳ android.widget.CompoundButton
           ↳ android.widget.CheckBox
             ↳ androidx.appcompat.widget.AppCompatCheckBox
               ↳ com.google.android.material.chip.Chip


Chips are compact elements that represent an attribute, text, entity, or action. They allow users to enter information, select a choice, filter content, or trigger an action.

The Chip widget is a thin view wrapper around the ChipDrawable, which contains all of the layout and draw logic. The extra logic exists to support touch, mouse, keyboard, and accessibility navigation. The main chip and close icon are considered to be separate logical sub-views, and contain their own navigation behavior and state.

All attributes from R.styleable.Chip are supported. Do not use the android:background attribute. It will be ignored because Chip manages its own background Drawable. Also do not use the android:drawableStart and android:drawableEnd attributes. They will be ignored because Chip manages its own start (app:chipIcon) and end (app:closeIcon) drawables. 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 and app:chipIconEnabled - Sets the icon of the chip. Usually on the left.
  • app:checkedIcon and app:checkedIconEnabled - Sets a custom icon to use when checked. Usually on the left.
  • app:closeIcon and app:closeIconEnabled - Sets a custom icon that the user can click to close. Usually on the right.

You can register a listener on the main chip with View.setOnClickListener(OnClickListener) or ERROR(/#setOnCheckedChangeListener(AppCompatCheckBox.OnCheckedChangeListener)). You can register a listener on the close icon with setOnCloseIconClickListener(OnClickListener).

For proper rendering of the ancestor TextView in RTL mode, call setLayoutDirection(int) with View.LAYOUT_DIRECTION_LOCALE. By default, TextView's layout rendering sets the text padding in LTR on initial rendering and it only renders correctly after the layout has been invalidated so you need to ensure that initial rendering has the correct layout.

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

See also:

Summary

XML attributes

Chip_android_checkable  
Chip_android_textAppearance  
Chip_checkedIcon  
Chip_checkedIconTint  
Chip_checkedIconVisible  
Chip_chipBackgroundColor  
Chip_chipCornerRadius  
Chip_chipEndPadding  
Chip_chipIcon  
Chip_chipIconSize  
Chip_chipIconTint  
Chip_chipIconVisible  
Chip_chipMinHeight  
Chip_chipStartPadding  
Chip_chipStrokeColor  
Chip_chipStrokeWidth  
Chip_closeIcon  
Chip_closeIconEndPadding  
Chip_closeIconSize  
Chip_closeIconStartPadding  
Chip_closeIconTint  
Chip_closeIconVisible  
Chip_ensureMinTouchTargetSize  
Chip_hideMotionSpec  
Chip_iconEndPadding  
Chip_iconStartPadding  
Chip_rippleColor  
Chip_showMotionSpec  
Chip_textEndPadding  
Chip_textStartPadding  

Inherited constants

Inherited fields

Public constructors

Chip(Context context)
Chip(Context context, AttributeSet attrs)
Chip(Context context, AttributeSet attrs, int defStyleAttr)

Public methods

boolean dispatchKeyEvent(KeyEvent event)
boolean ensureAccessibleTouchTarget(int minTargetPx)

Extends the touch target of this chip using a InsetDrawable if chip's intrinsic width / height is smaller than the minTargetPx.

CharSequence getAccessibilityClassName()
Drawable getBackgroundDrawable()
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.

Drawable getChipDrawable()

Returns the ChipDrawable backing this chip.

float getChipEndPadding()

Returns this chip's end padding.

Drawable getChipIcon()

Returns this chip's icon.

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.

CharSequence getChipText()

This method is deprecated. Use TextView.getText() instead.

Drawable getCloseIcon()

Returns this chip's close icon.

CharSequence getCloseIconContentDescription()

Returns this chip's close icon content description.

float getCloseIconEndPadding()

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

float getCloseIconSize()

Returns this chip's close icon size.

float getCloseIconStartPadding()

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

ColorStateList getCloseIconTint()

Returns the tint color for this chip's close icon.

TextUtils.TruncateAt getEllipsize()
void getFocusedRect(Rect r)
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.

ColorStateList getRippleColor()

Returns this chip's ripple color.

ShapeAppearanceModel getShapeAppearanceModel()

Returns the ShapeAppearanceModel used for the shape definition.

MotionSpec getShowMotionSpec()

Returns this chip's show motion spec.

float getTextEndPadding()

Returns the end padding for this chip's text.

float getTextStartPadding()

Returns the start padding for this chip's text.

boolean isCheckable()

Returns whether this chip is checkable.

boolean isCheckedIconEnabled()

This method is deprecated. Use isCheckedIconVisible() instead.

boolean isCheckedIconVisible()

Returns whether this chip's checked icon is visible.

boolean isChipIconEnabled()

This method is deprecated. Use isChipIconVisible() instead.

boolean isChipIconVisible()

Returns whether this chip's icon is visible.

boolean isCloseIconEnabled()

This method is deprecated. Use isCloseIconVisible() instead.

boolean isCloseIconVisible()

Returns whether this chip's close icon is visible.

void onChipDrawableSizeChange()

Handles a change in the ChipDrawable's size.

boolean onHoverEvent(MotionEvent event)
void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info)
PointerIcon onResolvePointerIcon(MotionEvent event, int pointerIndex)
void onRtlPropertiesChanged(int layoutDirection)
boolean onTouchEvent(MotionEvent event)
boolean performCloseIconClick()

Call this chip's close icon click listener, if it is defined.

void setAccessibilityClassName(CharSequence className)

Sets this chip's accessibility class name.

void setBackground(Drawable background)
void setBackgroundColor(int color)
void setBackgroundDrawable(Drawable background)
void setBackgroundResource(int resid)
void setBackgroundTintList(ColorStateList tint)
void setBackgroundTintMode(PorterDuff.Mode tintMode)
void setCheckable(boolean checkable)

Sets whether this chip is checkable.

void setCheckableResource(int id)

Sets whether this chip is checkable using a resource id.

void setChecked(boolean checked)
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 this chip's checked icon's color tint using the specified ColorStateList.

void setCheckedIconTintResource(int id)

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

void setCheckedIconVisible(int id)

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

void setCheckedIconVisible(boolean checkedIconVisible)

Sets whether this chip's checked icon is visible.

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 getShapeAppearanceModel(), modify the shape using the builder and then call setShapeAppearanceModel(ShapeAppearanceModel).

void setChipCornerRadiusResource(int id)

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

void setChipDrawable(ChipDrawable drawable)

Sets the ChipDrawable backing this chip.

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)

Sets this chip's icon.

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)

Sets this chip's icon using a resource 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 this chip icon's color tint using the specified ColorStateList.

void setChipIconTintResource(int id)

Sets this chip icon's color tint using a resource id.

void setChipIconVisible(int id)

Sets the visibility of this chip's icon using a resource id.

void setChipIconVisible(boolean chipIconVisible)

Sets whether this chip's icon is visible.

void setChipMinHeight(float minHeight)

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 setChipText(CharSequence chipText)

This method is deprecated. Use TextView.setText(CharSequence) instead.

void setChipTextResource(int id)

This method is deprecated. Use TextView.setText(int) instead.

void setCloseIcon(Drawable closeIcon)

Sets this chip's close icon.

void setCloseIconContentDescription(CharSequence closeIconContentDescription)

Sets the content description for this chip's close icon.

void setCloseIconEnabled(boolean closeIconEnabled)

This method is deprecated. Use setCloseIconVisible(boolean) 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)

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

void setCloseIconSize(float closeIconSize)

Sets this chip's close icon size.

void setCloseIconSizeResource(int id)

Sets this chip's close icon size using a resource 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.

void setCloseIconTint(ColorStateList closeIconTint)

Sets the tint color for this chip's close icon.

void setCloseIconTintResource(int id)

Sets the tint color for this chip's close icon using a resource id.

void setCloseIconVisible(boolean closeIconVisible)

Sets whether this chip close icon is visible.

void setCloseIconVisible(int id)

Sets whether this chip close icon is visible using a resource id.

void setCompoundDrawables(Drawable left, Drawable top, Drawable right, Drawable bottom)
void setCompoundDrawablesRelative(Drawable start, Drawable top, Drawable end, Drawable bottom)
void setCompoundDrawablesRelativeWithIntrinsicBounds(Drawable start, Drawable top, Drawable end, Drawable bottom)
void setCompoundDrawablesRelativeWithIntrinsicBounds(int start, int top, int end, int bottom)
void setCompoundDrawablesWithIntrinsicBounds(int left, int top, int right, int bottom)
void setCompoundDrawablesWithIntrinsicBounds(Drawable left, Drawable top, Drawable right, Drawable bottom)
void setElevation(float elevation)
void setEllipsize(TextUtils.TruncateAt where)
void setEnsureMinTouchTargetSize(boolean flag)

Sets whether this chip should expand its bounds (if needed) to meet the minimum touch target size.

void setGravity(int gravity)
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 setLayoutDirection(int layoutDirection)
void setLines(int lines)
void setMaxLines(int maxLines)
void setMaxWidth(int maxWidth)
void setMinLines(int minLines)
void setOnCheckedChangeListener(CompoundButton.OnCheckedChangeListener listener)
void setOnCloseIconClickListener(View.OnClickListener listener)

Register a callback to be invoked when the close icon is clicked.

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 setShapeAppearanceModel(ShapeAppearanceModel shapeAppearanceModel)

Sets the ShapeAppearanceModel that defines the shape.

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 setSingleLine(boolean singleLine)
void setText(CharSequence text, TextView.BufferType type)
void setTextAppearance(TextAppearance textAppearance)

Sets this chip's text appearance.

void setTextAppearance(int resId)
void setTextAppearance(Context context, int resId)
void setTextAppearanceResource(int id)

Sets this chip's text appearance using a resource 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 setTextSize(int unit, 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.

boolean shouldEnsureMinTouchTargetSize()

Returns whether this chip will expand its bounds (if needed) to meet the minimum touch target size.

Protected methods

boolean dispatchHoverEvent(MotionEvent event)
void drawableStateChanged()
void onAttachedToWindow()
int[] onCreateDrawableState(int extraSpace)
void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect)

Inherited methods

XML attributes

Chip_android_checkable

Related methods:

Chip_android_textAppearance

Related methods:

Chip_checkedIcon

Related methods:

Chip_checkedIconTint

Related methods:

Chip_checkedIconVisible

Related methods:

Chip_chipBackgroundColor

Related methods:

Chip_chipCornerRadius

Related methods:

Chip_chipEndPadding

Related methods:

Chip_chipIcon

Related methods:

Chip_chipIconSize

Related methods:

Chip_chipIconTint

Related methods:

Chip_chipIconVisible

Related methods:

Chip_chipMinHeight

Related methods:

Chip_chipStartPadding

Related methods:

Chip_chipStrokeColor

Related methods:

Chip_chipStrokeWidth

Related methods:

Chip_closeIcon

Related methods:

Chip_closeIconEndPadding

Related methods:

Chip_closeIconSize

Related methods:

Chip_closeIconStartPadding

Related methods:

Chip_closeIconTint

Related methods:

Chip_closeIconVisible

Related methods:

Chip_ensureMinTouchTargetSize

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 constructors

Chip

 public Chip (Context context)

Parameters
context Context

Chip

 public Chip (Context context, AttributeSet attrs)

Parameters
context Context

attrs AttributeSet

Chip

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

Parameters
context Context

attrs AttributeSet

defStyleAttr int

Public methods

dispatchKeyEvent

 public boolean dispatchKeyEvent (KeyEvent event)

Parameters
event KeyEvent

Returns
boolean

ensureAccessibleTouchTarget

 public boolean ensureAccessibleTouchTarget (int minTargetPx)

Extends the touch target of this chip using a InsetDrawable if chip's intrinsic width / height is smaller than the minTargetPx.

Parameters
minTargetPx int: minimum touch target size in pixel

Returns
boolean whether the background was changed

getAccessibilityClassName

 public CharSequence getAccessibilityClassName ()

Returns
CharSequence

getBackgroundDrawable

 public Drawable getBackgroundDrawable ()

Returns
Drawable

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.

Related XML Attributes:

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

getChipDrawable

 public Drawable getChipDrawable ()

Returns the ChipDrawable backing this chip.

Returns
Drawable

getChipEndPadding

 public float getChipEndPadding ()

Returns this chip's end padding.

Related XML Attributes:

Returns
float

getChipIcon

 public Drawable getChipIcon ()

Returns this chip's icon.

Related XML Attributes:

Returns
Drawable

getChipIconSize

 public float getChipIconSize ()

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

Related XML Attributes:

Returns
float

getChipIconTint

 public ColorStateList getChipIconTint ()

Returns the ColorStateList used to tint the chip icon.

Related XML Attributes:

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

getChipText

 public CharSequence getChipText ()

This method is deprecated.
Use TextView.getText() instead.

Returns this chip's text.

Returns
CharSequence

getCloseIcon

 public Drawable getCloseIcon ()

Returns this chip's close icon.

Related XML Attributes:

Returns
Drawable

getCloseIconContentDescription

 public CharSequence getCloseIconContentDescription ()

Returns this chip's close icon content description.

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 this chip's close icon size.

Related XML Attributes:

Returns
float

getCloseIconStartPadding

 public float getCloseIconStartPadding ()

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

Related XML Attributes:

Returns
float

getCloseIconTint

 public ColorStateList getCloseIconTint ()

Returns the tint color for this chip's close icon.

Related XML Attributes:

Returns
ColorStateList

getEllipsize

 public TextUtils.TruncateAt getEllipsize ()

Returns
TextUtils.TruncateAt

getFocusedRect

 public void getFocusedRect (Rect r)

Parameters
r Rect

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

getRippleColor

 public ColorStateList getRippleColor ()

Returns this chip's ripple color.

Related XML Attributes:

Returns
ColorStateList

getShapeAppearanceModel

 public ShapeAppearanceModel getShapeAppearanceModel ()

Returns the ShapeAppearanceModel used for the shape definition.

This ShapeAppearanceModel can be modified to change the shape.

Returns
ShapeAppearanceModel

getShowMotionSpec

 public MotionSpec getShowMotionSpec ()

Returns this chip's show motion spec.

Related XML Attributes:

Returns
MotionSpec

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

isCheckable

 public boolean isCheckable ()

Returns whether this chip is checkable.

Related XML Attributes:

Returns
boolean

isCheckedIconEnabled

 public boolean isCheckedIconEnabled ()

This method is deprecated.
Use isCheckedIconVisible() instead.

Returns
boolean

isCheckedIconVisible

 public boolean isCheckedIconVisible ()

Returns whether this chip's checked icon is visible.

Related XML Attributes:

Returns
boolean

isChipIconEnabled

 public boolean isChipIconEnabled ()

This method is deprecated.
Use isChipIconVisible() instead.

Returns
boolean

isChipIconVisible

 public boolean isChipIconVisible ()

Returns whether this chip's icon is visible.

Related XML Attributes:

Returns
boolean

isCloseIconEnabled

 public boolean isCloseIconEnabled ()

This method is deprecated.
Use isCloseIconVisible() instead.

Returns
boolean

isCloseIconVisible

 public boolean isCloseIconVisible ()

Returns whether this chip's close icon is visible.

Related XML Attributes:

Returns
boolean

onChipDrawableSizeChange

 public void onChipDrawableSizeChange ()

Handles a change in the ChipDrawable's size.

onHoverEvent

 public boolean onHoverEvent (MotionEvent event)

Parameters
event MotionEvent

Returns
boolean

onInitializeAccessibilityNodeInfo

 public void onInitializeAccessibilityNodeInfo (AccessibilityNodeInfo info)

Parameters
info AccessibilityNodeInfo

onResolvePointerIcon

 public PointerIcon onResolvePointerIcon (MotionEvent event, int pointerIndex)

Parameters
event MotionEvent

pointerIndex int

Returns
PointerIcon

onRtlPropertiesChanged

 public void onRtlPropertiesChanged (int layoutDirection)

Parameters
layoutDirection int

onTouchEvent

 public boolean onTouchEvent (MotionEvent event)

Parameters
event MotionEvent

Returns
boolean

performCloseIconClick

 public boolean performCloseIconClick ()

Call this chip's close icon click listener, if it is defined. Performs all normal actions associated with clicking: reporting accessibility event, playing a sound, etc.

Returns
boolean True there was an assigned close icon click listener that was called, false otherwise is returned.

setAccessibilityClassName

 public void setAccessibilityClassName (CharSequence className)

Sets this chip's accessibility class name.

Parameters
className CharSequence: This chip's accessibility class name.

setBackground

 public void setBackground (Drawable background)

Parameters
background Drawable

setBackgroundColor

 public void setBackgroundColor (int color)

Parameters
color int

setBackgroundDrawable

 public void setBackgroundDrawable (Drawable background)

Parameters
background Drawable

setBackgroundResource

 public void setBackgroundResource (int resid)

Parameters
resid int

setBackgroundTintList

 public void setBackgroundTintList (ColorStateList tint)

Parameters
tint ColorStateList

setBackgroundTintMode

 public void setBackgroundTintMode (PorterDuff.Mode tintMode)

Parameters
tintMode PorterDuff.Mode

setCheckable

 public void setCheckable (boolean checkable)

Sets whether this chip is checkable.

Related XML Attributes:

Parameters
checkable boolean: Whether this chip is checkable.

setCheckableResource

 public void setCheckableResource (int id)

Sets whether this chip is checkable using a resource id.

Related XML Attributes:

Parameters
id int: The resource id of this chip is checkable.

setChecked

 public void setChecked (boolean checked)

Parameters
checked boolean

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 this chip's checked icon's color tint using the specified ColorStateList.

Related XML Attributes:

Parameters
checkedIconTint ColorStateList: The tint color of this chip's checked icon.

setCheckedIconTintResource

 public void setCheckedIconTintResource (int id)

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

Related XML Attributes:

Parameters
id int: The resource id for tinting the checked icon.

setCheckedIconVisible

 public void setCheckedIconVisible (int id)

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

Related XML Attributes:

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

setCheckedIconVisible

 public void setCheckedIconVisible (boolean checkedIconVisible)

Sets whether this chip's checked icon is visible.

Related XML Attributes:

Parameters
checkedIconVisible boolean: This chip's checked icon visibility.

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 getShapeAppearanceModel(), modify the shape using the builder and then call 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 getShapeAppearanceModel(), modify the shape using the builder and then call setShapeAppearanceModel(ShapeAppearanceModel).

Parameters
id int

setChipDrawable

 public void setChipDrawable (ChipDrawable drawable)

Sets the ChipDrawable backing this chip.

Parameters
drawable ChipDrawable

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)

Sets this chip's icon.

Related XML Attributes:

Parameters
chipIcon Drawable: drawable of this chip's icon.

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)

Sets this chip's icon using a resource id.

Related XML Attributes:

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

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 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 this chip icon's color tint using the specified ColorStateList.

Related XML Attributes:

Parameters
chipIconTint ColorStateList: The tint color of this chip's icon.

setChipIconTintResource

 public void setChipIconTintResource (int id)

Sets this chip icon's color tint using a resource id.

Related XML Attributes:

Parameters
id int: The resource id for tinting the chip icon.

setChipIconVisible

 public void setChipIconVisible (int id)

Sets the visibility of this chip's icon using a resource id.

Related XML Attributes:

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

setChipIconVisible

 public void setChipIconVisible (boolean chipIconVisible)

Sets whether this chip's icon is visible.

Parameters
chipIconVisible boolean: The visibility of this chip's icon.

setChipMinHeight

 public void setChipMinHeight (float minHeight)

Sets this chip's minimum height.

Related XML Attributes:

Parameters
minHeight float: This chip's minimum 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 minimum 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.

setChipText

 public void setChipText (CharSequence chipText)

This method is deprecated.
Use TextView.setText(CharSequence) instead.

Parameters
chipText CharSequence

setChipTextResource

 public void setChipTextResource (int id)

This method is deprecated.
Use TextView.setText(int) instead.

Parameters
id int

setCloseIcon

 public void setCloseIcon (Drawable closeIcon)

Sets this chip's close icon.

Related XML Attributes:

Parameters
closeIcon Drawable: This chip's close icon.

setCloseIconContentDescription

 public void setCloseIconContentDescription (CharSequence closeIconContentDescription)

Sets the content description for this chip's close icon.

Parameters
closeIconContentDescription CharSequence: The content description for this chip's close icon.

setCloseIconEnabled

 public void setCloseIconEnabled (boolean closeIconEnabled)

This method is deprecated.
Use setCloseIconVisible(boolean) 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)

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

Related XML Attributes:

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

setCloseIconSize

 public void setCloseIconSize (float closeIconSize)

Sets this chip's close icon size.

Related XML Attributes:

Parameters
closeIconSize float: This chip's close icon size.

setCloseIconSizeResource

 public void setCloseIconSizeResource (int id)

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

Related XML Attributes:

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

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.

setCloseIconTint

 public void setCloseIconTint (ColorStateList closeIconTint)

Sets the tint color for this chip's close icon.

Related XML Attributes:

Parameters
closeIconTint ColorStateList: This chip's close icon tint.

setCloseIconTintResource

 public void setCloseIconTintResource (int id)

Sets the tint color for this chip's close icon using a resource id.

Related XML Attributes:

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

setCloseIconVisible

 public void setCloseIconVisible (boolean closeIconVisible)

Sets whether this chip close icon is visible.

Related XML Attributes:

Parameters
closeIconVisible boolean: This chip's close icon visibility.

setCloseIconVisible

 public void setCloseIconVisible (int id)

Sets whether this chip close icon is visible using a resource id.

Related XML Attributes:

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

setCompoundDrawables

 public void setCompoundDrawables (Drawable left, Drawable top, Drawable right, Drawable bottom)

Parameters
left Drawable

top Drawable

right Drawable

bottom Drawable

setCompoundDrawablesRelative

 public void setCompoundDrawablesRelative (Drawable start, Drawable top, Drawable end, Drawable bottom)

Parameters
start Drawable

top Drawable

end Drawable

bottom Drawable

setCompoundDrawablesRelativeWithIntrinsicBounds

 public void setCompoundDrawablesRelativeWithIntrinsicBounds (Drawable start, Drawable top, Drawable end, Drawable bottom)

Parameters
start Drawable

top Drawable

end Drawable

bottom Drawable

setCompoundDrawablesRelativeWithIntrinsicBounds

 public void setCompoundDrawablesRelativeWithIntrinsicBounds (int start, int top, int end, int bottom)

Parameters
start int

top int

end int

bottom int

setCompoundDrawablesWithIntrinsicBounds

 public void setCompoundDrawablesWithIntrinsicBounds (int left, int top, int right, int bottom)

Parameters
left int

top int

right int

bottom int

setCompoundDrawablesWithIntrinsicBounds

 public void setCompoundDrawablesWithIntrinsicBounds (Drawable left, Drawable top, Drawable right, Drawable bottom)

Parameters
left Drawable

top Drawable

right Drawable

bottom Drawable

setElevation

 public void setElevation (float elevation)

Parameters
elevation float

setEllipsize

 public void setEllipsize (TextUtils.TruncateAt where)

Parameters
where TextUtils.TruncateAt

setEnsureMinTouchTargetSize

 public void setEnsureMinTouchTargetSize (boolean flag)

Sets whether this chip should expand its bounds (if needed) to meet the minimum touch target size.

Related XML Attributes:

Parameters
flag boolean: Whether this chip should meet the min touch target size.

setGravity

 public void setGravity (int gravity)

Parameters
gravity int

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.

setLayoutDirection

 public void setLayoutDirection (int layoutDirection)

Parameters
layoutDirection int

setLines

 public void setLines (int lines)

Parameters
lines int

setMaxLines

 public void setMaxLines (int maxLines)

Parameters
maxLines int

setMaxWidth

 public void setMaxWidth (int maxWidth)

Parameters
maxWidth int

setMinLines

 public void setMinLines (int minLines)

Parameters
minLines int

setOnCheckedChangeListener

 public void setOnCheckedChangeListener (CompoundButton.OnCheckedChangeListener listener)

Parameters
listener CompoundButton.OnCheckedChangeListener

setOnCloseIconClickListener

 public void setOnCloseIconClickListener (View.OnClickListener listener)

Register a callback to be invoked when the close icon is clicked.

Parameters
listener View.OnClickListener

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.

setShapeAppearanceModel

 public void setShapeAppearanceModel (ShapeAppearanceModel shapeAppearanceModel)

Sets the ShapeAppearanceModel that defines the shape.

Parameters
shapeAppearanceModel ShapeAppearanceModel

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.

setSingleLine

 public void setSingleLine (boolean singleLine)

Parameters
singleLine boolean

setText

 public void setText (CharSequence text, TextView.BufferType type)

Parameters
text CharSequence

type TextView.BufferType

setTextAppearance

 public void setTextAppearance (TextAppearance textAppearance)

Sets this chip's text appearance.

Related XML Attributes:

Parameters
textAppearance TextAppearance: This chip's text appearance.

setTextAppearance

 public void setTextAppearance (int resId)

Parameters
resId int

setTextAppearance

 public void setTextAppearance (Context context, int resId)

Parameters
context Context

resId int

setTextAppearanceResource

 public void setTextAppearanceResource (int id)

Sets this chip's text appearance using a resource id.

Related XML Attributes:

Parameters
id int: The resource id of this chip's text appearance.

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.

setTextSize

 public void setTextSize (int unit, float size)

Parameters
unit int

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.

shouldEnsureMinTouchTargetSize

 public boolean shouldEnsureMinTouchTargetSize ()

Returns whether this chip will expand its bounds (if needed) to meet the minimum touch target size.

Related XML Attributes:

Returns
boolean

Protected methods

dispatchHoverEvent

 protected boolean dispatchHoverEvent (MotionEvent event)

Parameters
event MotionEvent

Returns
boolean

drawableStateChanged

 protected void drawableStateChanged ()

onAttachedToWindow

 protected void onAttachedToWindow ()

onCreateDrawableState

 protected int[] onCreateDrawableState (int extraSpace)

Parameters
extraSpace int

Returns
int[]

onFocusChanged

 protected void onFocusChanged (boolean focused, int direction, Rect previouslyFocusedRect)

Parameters
focused boolean

direction int

previouslyFocusedRect Rect