Chip
public
class
Chip
extends AppCompatCheckBox
implements
ChipDrawable.Delegate,
Shapeable
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 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
andapp:chipIconEnabled
- Sets the icon of the chip. Usually on the left.app:checkedIcon
andapp:checkedIconEnabled
- Sets a custom icon to use when checked. Usually on the left.app:closeIcon
andapp: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 setOnClickListener(OnClickListener)
or setOnCheckedChangeListener(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.
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 |
---|
![]()
android.widget.TextView
|
![]()
android.view.View
|
Inherited fields |
---|
![]()
android.view.View
|
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 |
Drawable
|
getBackgroundDrawable()
|
Drawable
|
getCheckedIcon()
Returns this chip's checked icon. |
ColorStateList
|
getCheckedIconTint()
Returns the |
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 |
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 |
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 |
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 |
boolean
|
isCheckedIconVisible()
Returns whether this chip's checked icon is visible. |
boolean
|
isChipIconEnabled()
This method is deprecated.
Use |
boolean
|
isChipIconVisible()
Returns whether this chip's icon is visible. |
boolean
|
isCloseIconEnabled()
This method is deprecated.
Use |
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
|
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 |
void
|
setCheckedIconEnabledResource(int id)
This method is deprecated.
Use |
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 |
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 |
void
|
setChipCornerRadiusResource(int id)
This method is deprecated.
call |
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 |
void
|
setChipIconEnabledResource(int id)
This method is deprecated.
Use |
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 |
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 |
void
|
setChipTextResource(int id)
This method is deprecated.
Use |
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 |
void
|
setCloseIconEnabledResource(int id)
This method is deprecated.
Use |
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
|
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 |
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
|
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 | |
---|---|
![]()
androidx.appcompat.widget.AppCompatCheckBox
| |
![]()
android.widget.CheckBox
| |
![]()
android.widget.CompoundButton
| |
![]()
android.widget.Button
| |
![]()
android.widget.TextView
| |
![]()
android.view.View
| |
![]()
java.lang.Object
| |
![]()
androidx.core.widget.TintableCompoundButton
| |
![]()
androidx.core.view.TintableBackgroundView
| |
![]()
android.widget.Checkable
| |
![]()
android.view.ViewTreeObserver.OnPreDrawListener
| |
![]()
android.graphics.drawable.Drawable.Callback
| |
![]()
android.view.KeyEvent.Callback
| |
![]()
android.view.accessibility.AccessibilityEventSource
| |
![]()
com.google.android.material.chip.ChipDrawable.Delegate
| |
![]()
com.google.android.material.shape.Shapeable
|
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
Chip (Context context)
Parameters | |
---|---|
context |
Context |
Chip
Chip (Context context, AttributeSet attrs)
Parameters | |
---|---|
context |
Context |
attrs |
AttributeSet |
Chip
Chip (Context context, AttributeSet attrs, int defStyleAttr)
Parameters | |
---|---|
context |
Context |
attrs |
AttributeSet |
defStyleAttr |
int |
Public methods
dispatchKeyEvent
boolean dispatchKeyEvent (KeyEvent event)
Parameters | |
---|---|
event |
KeyEvent |
Returns | |
---|---|
boolean |
ensureAccessibleTouchTarget
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 |
getBackgroundDrawable
Drawable getBackgroundDrawable ()
Returns | |
---|---|
Drawable |
getCheckedIcon
Drawable getCheckedIcon ()
Returns this chip's checked icon.
Related XML Attributes:
Returns | |
---|---|
Drawable |
See also:
getCheckedIconTint
ColorStateList getCheckedIconTint ()
Returns the ColorStateList
used to tint the checked icon.
Related XML Attributes:
Returns | |
---|---|
ColorStateList |
See also:
getChipBackgroundColor
ColorStateList getChipBackgroundColor ()
Returns this chip's background color.
Related XML Attributes:
Returns | |
---|---|
ColorStateList |
See also:
getChipCornerRadius
float getChipCornerRadius ()
Returns this chip's corner radius.
Related XML Attributes:
Returns | |
---|---|
float |
See also:
getChipDrawable
Drawable getChipDrawable ()
Returns the ChipDrawable backing this chip.
Returns | |
---|---|
Drawable |
getChipEndPadding
float getChipEndPadding ()
Returns this chip's end padding.
Related XML Attributes:
Returns | |
---|---|
float |
See also:
getChipIcon
Drawable getChipIcon ()
Returns this chip's icon.
Related XML Attributes:
Returns | |
---|---|
Drawable |
See also:
getChipIconSize
float getChipIconSize ()
Returns this chip's icon size.
Related XML Attributes:
Returns | |
---|---|
float |
See also:
getChipIconTint
ColorStateList getChipIconTint ()
Returns the ColorStateList
used to tint the chip icon.
Related XML Attributes:
Returns | |
---|---|
ColorStateList |
See also:
getChipMinHeight
float getChipMinHeight ()
Returns this chip's minimum height.
Related XML Attributes:
Returns | |
---|---|
float |
See also:
getChipStartPadding
float getChipStartPadding ()
Returns this chip's start padding.
Related XML Attributes:
Returns | |
---|---|
float |
See also:
getChipStrokeColor
ColorStateList getChipStrokeColor ()
Returns this chip's stroke color.
Related XML Attributes:
Returns | |
---|---|
ColorStateList |
See also:
getChipStrokeWidth
float getChipStrokeWidth ()
Returns this chip's stroke width.
Related XML Attributes:
Returns | |
---|---|
float |
See also:
getChipText
CharSequence getChipText ()
This method is deprecated.
Use getText()
instead.
Returns this chip's text.
Returns | |
---|---|
CharSequence |
getCloseIcon
Drawable getCloseIcon ()
Returns this chip's close icon.
Related XML Attributes:
Returns | |
---|---|
Drawable |
See also:
getCloseIconContentDescription
CharSequence getCloseIconContentDescription ()
Returns this chip's close icon content description.
Returns | |
---|---|
CharSequence |
getCloseIconEndPadding
float getCloseIconEndPadding ()
Returns the end padding for this chip's close icon.
Related XML Attributes:
Returns | |
---|---|
float |
See also:
getCloseIconSize
float getCloseIconSize ()
Returns this chip's close icon size.
Related XML Attributes:
Returns | |
---|---|
float |
See also:
getCloseIconStartPadding
float getCloseIconStartPadding ()
Returns the start padding for this chip's close icon.
Related XML Attributes:
Returns | |
---|---|
float |
See also:
getCloseIconTint
ColorStateList getCloseIconTint ()
Returns the tint color for this chip's close icon.
Related XML Attributes:
Returns | |
---|---|
ColorStateList |
See also:
getEllipsize
TextUtils.TruncateAt getEllipsize ()
Returns | |
---|---|
TextUtils.TruncateAt |
getFocusedRect
void getFocusedRect (Rect r)
Parameters | |
---|---|
r |
Rect |
getHideMotionSpec
MotionSpec getHideMotionSpec ()
Returns this chip's hide motion spec.
Related XML Attributes:
Returns | |
---|---|
MotionSpec |
See also:
getIconEndPadding
float getIconEndPadding ()
Returns the end padding for this chip's icon.
Related XML Attributes:
Returns | |
---|---|
float |
See also:
getIconStartPadding
float getIconStartPadding ()
Returns the start padding for this chip's icon.
Related XML Attributes:
Returns | |
---|---|
float |
See also:
getRippleColor
ColorStateList getRippleColor ()
Returns this chip's ripple color.
Related XML Attributes:
Returns | |
---|---|
ColorStateList |
See also:
getShapeAppearanceModel
ShapeAppearanceModel getShapeAppearanceModel ()
Returns the ShapeAppearanceModel
used for the shape definition.
This ShapeAppearanceModel
can be modified to change the shape.
Returns | |
---|---|
ShapeAppearanceModel |
getShowMotionSpec
MotionSpec getShowMotionSpec ()
Returns this chip's show motion spec.
Related XML Attributes:
Returns | |
---|---|
MotionSpec |
See also:
getTextEndPadding
float getTextEndPadding ()
Returns the end padding for this chip's text.
Related XML Attributes:
Returns | |
---|---|
float |
See also:
getTextStartPadding
float getTextStartPadding ()
Returns the start padding for this chip's text.
Related XML Attributes:
Returns | |
---|---|
float |
See also:
isCheckable
boolean isCheckable ()
Returns whether this chip is checkable.
Related XML Attributes:
Returns | |
---|---|
boolean |
See also:
isCheckedIconEnabled
boolean isCheckedIconEnabled ()
This method is deprecated.
Use isCheckedIconVisible()
instead.
Returns | |
---|---|
boolean |
isCheckedIconVisible
boolean isCheckedIconVisible ()
Returns whether this chip's checked icon is visible.
Related XML Attributes:
Returns | |
---|---|
boolean |
See also:
isChipIconEnabled
boolean isChipIconEnabled ()
This method is deprecated.
Use isChipIconVisible()
instead.
Returns | |
---|---|
boolean |
isChipIconVisible
boolean isChipIconVisible ()
Returns whether this chip's icon is visible.
Related XML Attributes:
Returns | |
---|---|
boolean |
See also:
isCloseIconEnabled
boolean isCloseIconEnabled ()
This method is deprecated.
Use isCloseIconVisible()
instead.
Returns | |
---|---|
boolean |
isCloseIconVisible
boolean isCloseIconVisible ()
Returns whether this chip's close icon is visible.
Related XML Attributes:
Returns | |
---|---|
boolean |
onChipDrawableSizeChange
void onChipDrawableSizeChange ()
Handles a change in the ChipDrawable's size.
onHoverEvent
boolean onHoverEvent (MotionEvent event)
Parameters | |
---|---|
event |
MotionEvent |
Returns | |
---|---|
boolean |
onInitializeAccessibilityNodeInfo
void onInitializeAccessibilityNodeInfo (AccessibilityNodeInfo info)
Parameters | |
---|---|
info |
AccessibilityNodeInfo |
onResolvePointerIcon
PointerIcon onResolvePointerIcon (MotionEvent event, int pointerIndex)
Parameters | |
---|---|
event |
MotionEvent |
pointerIndex |
int |
Returns | |
---|---|
PointerIcon |
onRtlPropertiesChanged
void onRtlPropertiesChanged (int layoutDirection)
Parameters | |
---|---|
layoutDirection |
int |
onTouchEvent
boolean onTouchEvent (MotionEvent event)
Parameters | |
---|---|
event |
MotionEvent |
Returns | |
---|---|
boolean |
performCloseIconClick
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. |
setBackground
void setBackground (Drawable background)
Parameters | |
---|---|
background |
Drawable |
setBackgroundColor
void setBackgroundColor (int color)
Parameters | |
---|---|
color |
int |
setBackgroundDrawable
void setBackgroundDrawable (Drawable background)
Parameters | |
---|---|
background |
Drawable |
setBackgroundResource
void setBackgroundResource (int resid)
Parameters | |
---|---|
resid |
int |
setBackgroundTintList
void setBackgroundTintList (ColorStateList tint)
Parameters | |
---|---|
tint |
ColorStateList |
setBackgroundTintMode
void setBackgroundTintMode (PorterDuff.Mode tintMode)
Parameters | |
---|---|
tintMode |
PorterDuff.Mode |
setCheckable
void setCheckable (boolean checkable)
Sets whether this chip is checkable.
Related XML Attributes:
Parameters | |
---|---|
checkable |
boolean : Whether this chip is checkable. |
setCheckableResource
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
void setChecked (boolean checked)
Parameters | |
---|---|
checked |
boolean |
setCheckedIcon
void setCheckedIcon (Drawable checkedIcon)
Sets this chip's checked icon.
Related XML Attributes:
Parameters | |
---|---|
checkedIcon |
Drawable : This chip's checked icon. |
setCheckedIconEnabled
void setCheckedIconEnabled (boolean checkedIconEnabled)
This method is deprecated.
Use setCheckedIconVisible(boolean)
instead.
Parameters | |
---|---|
checkedIconEnabled |
boolean |
setCheckedIconEnabledResource
void setCheckedIconEnabledResource (int id)
This method is deprecated.
Use setCheckedIconVisible(int)
instead.
Parameters | |
---|---|
id |
int |
setCheckedIconResource
void setCheckedIconResource (int id)
Sets this chip's checked icon using a resource id.
Related XML Attributes:
Parameters | |
---|---|
id |
int : The resource id of this chip's checked icon. |
setCheckedIconTint
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
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
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
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
void setChipBackgroundColor (ColorStateList chipBackgroundColor)
Sets this chip's background color.
Related XML Attributes:
Parameters | |
---|---|
chipBackgroundColor |
ColorStateList : This chip's background color. |
setChipBackgroundColorResource
void setChipBackgroundColorResource (int id)
Sets this chip's background color using a resource id.
Related XML Attributes:
Parameters | |
---|---|
id |
int : The resource id of this chip's background color. |
setChipCornerRadius
void setChipCornerRadius (float chipCornerRadius)
This method is deprecated.
call withCornerSize(float)
or call toBuilder()
on the getShapeAppearanceModel()
, modify the
shape using the builder and then call setShapeAppearanceModel(ShapeAppearanceModel)
.
Parameters | |
---|---|
chipCornerRadius |
float |
setChipCornerRadiusResource
void setChipCornerRadiusResource (int id)
This method is deprecated.
call withCornerSize(float)
or call toBuilder()
on the getShapeAppearanceModel()
, modify the
shape using the builder and then call setShapeAppearanceModel(ShapeAppearanceModel)
.
Parameters | |
---|---|
id |
int |
setChipDrawable
void setChipDrawable (ChipDrawable drawable)
Sets the ChipDrawable backing this chip.
Parameters | |
---|---|
drawable |
ChipDrawable |
setChipEndPadding
void setChipEndPadding (float chipEndPadding)
Sets this chip's end padding.
Related XML Attributes:
Parameters | |
---|---|
chipEndPadding |
float : This chip's end padding. |
setChipEndPaddingResource
void setChipEndPaddingResource (int id)
Sets this chip's end padding using a resource id.
Related XML Attributes:
Parameters | |
---|---|
id |
int : The resource id for this chip's end padding. |
setChipIcon
void setChipIcon (Drawable chipIcon)
Sets this chip's icon.
Related XML Attributes:
Parameters | |
---|---|
chipIcon |
Drawable : drawable of this chip's icon. |
setChipIconEnabled
void setChipIconEnabled (boolean chipIconEnabled)
This method is deprecated.
Use setChipIconVisible(boolean)
instead.
Parameters | |
---|---|
chipIconEnabled |
boolean |
setChipIconEnabledResource
void setChipIconEnabledResource (int id)
This method is deprecated.
Use setChipIconVisible(int)
instead.
Parameters | |
---|---|
id |
int |
setChipIconResource
void setChipIconResource (int id)
Sets this chip's icon using a resource id.
Related XML Attributes:
Parameters | |
---|---|
id |
int : The resource id for this chip's icon. |
setChipIconSize
void setChipIconSize (float chipIconSize)
Sets this chip icon's size.
Related XML Attributes:
Parameters | |
---|---|
chipIconSize |
float : This chip's icon size. |
setChipIconSizeResource
void setChipIconSizeResource (int id)
Sets this chip icon's size using a resource id.
Related XML Attributes:
Parameters | |
---|---|
id |
int : The resource id of this chip's icon size. |
setChipIconTint
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
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
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
void setChipIconVisible (boolean chipIconVisible)
Sets whether this chip's icon is visible.
Parameters | |
---|---|
chipIconVisible |
boolean : The visibility of this chip's icon. |
setChipMinHeight
void setChipMinHeight (float minHeight)
Sets this chip's minimum height.
Related XML Attributes:
Parameters | |
---|---|
minHeight |
float : This chip's mininum height. |
setChipMinHeightResource
void setChipMinHeightResource (int id)
Sets this chip's minimum height using a resource id.
Related XML Attributes:
Parameters | |
---|---|
id |
int : The resource id of this chip's mininum height. |
setChipStartPadding
void setChipStartPadding (float chipStartPadding)
Sets this chip's start padding.
Related XML Attributes:
Parameters | |
---|---|
chipStartPadding |
float : This chip's start padding. |
setChipStartPaddingResource
void setChipStartPaddingResource (int id)
Sets this chip's start padding using a resource id.
Related XML Attributes:
Parameters | |
---|---|
id |
int : The resource id of this chip's start padding. |
setChipStrokeColor
void setChipStrokeColor (ColorStateList chipStrokeColor)
Sets this chip's stroke color.
Related XML Attributes:
Parameters | |
---|---|
chipStrokeColor |
ColorStateList : This chip's stroke color. |
setChipStrokeColorResource
void setChipStrokeColorResource (int id)
Sets this chip's stroke color using a resource id.
Related XML Attributes:
Parameters | |
---|---|
id |
int : The resource id of this chip's stroke color. |
setChipStrokeWidth
void setChipStrokeWidth (float chipStrokeWidth)
Sets this chip's stroke width.
Related XML Attributes:
Parameters | |
---|---|
chipStrokeWidth |
float : This chip's stroke width. |
setChipStrokeWidthResource
void setChipStrokeWidthResource (int id)
Sets this chip's stroke width using a resource id.
Related XML Attributes:
Parameters | |
---|---|
id |
int : The resource id of this chip's stroke width. |
setChipText
void setChipText (CharSequence chipText)
This method is deprecated.
Use setText(CharSequence)
instead.
Parameters | |
---|---|
chipText |
CharSequence |
setChipTextResource
void setChipTextResource (int id)
This method is deprecated.
Use setText(int)
instead.
Parameters | |
---|---|
id |
int |
setCloseIcon
void setCloseIcon (Drawable closeIcon)
Sets this chip's close icon.
Related XML Attributes:
Parameters | |
---|---|
closeIcon |
Drawable : This chip's close icon. |
setCloseIconContentDescription
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
void setCloseIconEnabled (boolean closeIconEnabled)
This method is deprecated.
Use setCloseIconVisible(boolean)
instead.
Parameters | |
---|---|
closeIconEnabled |
boolean |
setCloseIconEnabledResource
void setCloseIconEnabledResource (int id)
This method is deprecated.
Use setCloseIconVisible(int)
instead.
Parameters | |
---|---|
id |
int |
setCloseIconEndPadding
void setCloseIconEndPadding (float closeIconEndPadding)
Sets the end padding for this chip's close icon.
Related XML Attributes:
Parameters | |
---|---|
closeIconEndPadding |
float : The end padding of this chip's close icon. |
setCloseIconEndPaddingResource
void setCloseIconEndPaddingResource (int id)
Sets the end padding for this chip's close icon using a resource id.
Related XML Attributes:
Parameters | |
---|---|
id |
int : The resource id for the end padding of this chip's close icon. |
setCloseIconResource
void setCloseIconResource (int id)
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
void setCloseIconSize (float closeIconSize)
Sets this chip's close icon size.
Related XML Attributes:
Parameters | |
---|---|
closeIconSize |
float : This chip's close icon size. |
setCloseIconSizeResource
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
void setCloseIconStartPadding (float closeIconStartPadding)
Sets the start padding for this chip's close icon.
Related XML Attributes:
Parameters | |
---|---|
closeIconStartPadding |
float : The start padding of this chip's close icon. |
setCloseIconStartPaddingResource
void setCloseIconStartPaddingResource (int id)
Sets the start padding for this chip's close icon using a resource id.
Related XML Attributes:
Parameters | |
---|---|
id |
int : The resource id for the start padding of this chip's close icon. |
setCloseIconTint
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
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
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
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
void setCompoundDrawables (Drawable left, Drawable top, Drawable right, Drawable bottom)
Parameters | |
---|---|
left |
Drawable |
top |
Drawable |
right |
Drawable |
bottom |
Drawable |
setCompoundDrawablesRelative
void setCompoundDrawablesRelative (Drawable start, Drawable top, Drawable end, Drawable bottom)
Parameters | |
---|---|
start |
Drawable |
top |
Drawable |
end |
Drawable |
bottom |
Drawable |
setCompoundDrawablesRelativeWithIntrinsicBounds
void setCompoundDrawablesRelativeWithIntrinsicBounds (Drawable start, Drawable top, Drawable end, Drawable bottom)
Parameters | |
---|---|
start |
Drawable |
top |
Drawable |
end |
Drawable |
bottom |
Drawable |
setCompoundDrawablesRelativeWithIntrinsicBounds
void setCompoundDrawablesRelativeWithIntrinsicBounds (int start, int top, int end, int bottom)
Parameters | |
---|---|
start |
int |
top |
int |
end |
int |
bottom |
int |
setCompoundDrawablesWithIntrinsicBounds
void setCompoundDrawablesWithIntrinsicBounds (int left, int top, int right, int bottom)
Parameters | |
---|---|
left |
int |
top |
int |
right |
int |
bottom |
int |
setCompoundDrawablesWithIntrinsicBounds
void setCompoundDrawablesWithIntrinsicBounds (Drawable left, Drawable top, Drawable right, Drawable bottom)
Parameters | |
---|---|
left |
Drawable |
top |
Drawable |
right |
Drawable |
bottom |
Drawable |
setElevation
void setElevation (float elevation)
Parameters | |
---|---|
elevation |
float |
setEllipsize
void setEllipsize (TextUtils.TruncateAt where)
Parameters | |
---|---|
where |
TextUtils.TruncateAt |
setEnsureMinTouchTargetSize
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
void setGravity (int gravity)
Parameters | |
---|---|
gravity |
int |
setHideMotionSpec
void setHideMotionSpec (MotionSpec hideMotionSpec)
Sets this chip's hide motion spec.
Related XML Attributes:
Parameters | |
---|---|
hideMotionSpec |
MotionSpec : This chip's hide motion spec. |
setHideMotionSpecResource
void setHideMotionSpecResource (int id)
Sets this chip's hide motion spec using a resource id.
Related XML Attributes:
Parameters | |
---|---|
id |
int : The resource id of this chip's hide motion spec. |
setIconEndPadding
void setIconEndPadding (float iconEndPadding)
Sets the end padding for this chip's icon.
Related XML Attributes:
Parameters | |
---|---|
iconEndPadding |
float : The end padding of this chip's icon. |
setIconEndPaddingResource
void setIconEndPaddingResource (int id)
Sets the end padding for this chip's icon using a resource id.
Related XML Attributes:
Parameters | |
---|---|
id |
int : The resource id for the end padding of this chip's icon. |
setIconStartPadding
void setIconStartPadding (float iconStartPadding)
Sets this chip's icon start padding.
Related XML Attributes:
Parameters | |
---|---|
iconStartPadding |
float : The start padding of this chip's icon. |
setIconStartPaddingResource
void setIconStartPaddingResource (int id)
Sets the start padding for this chip's icon using a resource id.
Related XML Attributes:
Parameters | |
---|---|
id |
int : The resource id for the start padding of this chip's icon. |
setLayoutDirection
void setLayoutDirection (int layoutDirection)
Parameters | |
---|---|
layoutDirection |
int |
setLines
void setLines (int lines)
Parameters | |
---|---|
lines |
int |
setMaxLines
void setMaxLines (int maxLines)
Parameters | |
---|---|
maxLines |
int |
setMaxWidth
void setMaxWidth (int maxWidth)
Parameters | |
---|---|
maxWidth |
int |
setMinLines
void setMinLines (int minLines)
Parameters | |
---|---|
minLines |
int |
setOnCloseIconClickListener
void setOnCloseIconClickListener (View.OnClickListener listener)
Register a callback to be invoked when the close icon is clicked.
Parameters | |
---|---|
listener |
View.OnClickListener |
setRippleColor
void setRippleColor (ColorStateList rippleColor)
Sets this chip's ripple color.
Related XML Attributes:
Parameters | |
---|---|
rippleColor |
ColorStateList : This chip's ripple color. |
setRippleColorResource
void setRippleColorResource (int id)
Sets this chip's ripple color using a resource id.
Related XML Attributes:
Parameters | |
---|---|
id |
int : The resource id of this chip's ripple color. |
setShapeAppearanceModel
void setShapeAppearanceModel (ShapeAppearanceModel shapeAppearanceModel)
Sets the ShapeAppearanceModel
that defines the shape.
Parameters | |
---|---|
shapeAppearanceModel |
ShapeAppearanceModel |
setShowMotionSpec
void setShowMotionSpec (MotionSpec showMotionSpec)
Sets this chip's show motion spec.
Related XML Attributes:
Parameters | |
---|---|
showMotionSpec |
MotionSpec : This chip's show motion spec. |
setShowMotionSpecResource
void setShowMotionSpecResource (int id)
Sets this chip's show motion spec using a resource id.
Related XML Attributes:
Parameters | |
---|---|
id |
int : The resource id of this chip's show motion spec. |
setSingleLine
void setSingleLine (boolean singleLine)
Parameters | |
---|---|
singleLine |
boolean |
setText
void setText (CharSequence text, TextView.BufferType type)
Parameters | |
---|---|
text |
CharSequence |
type |
TextView.BufferType |
setTextAppearance
void setTextAppearance (TextAppearance textAppearance)
Sets this chip's text appearance.
Related XML Attributes:
Parameters | |
---|---|
textAppearance |
TextAppearance : This chip's text appearance. |
setTextAppearance
void setTextAppearance (int resId)
Parameters | |
---|---|
resId |
int |
setTextAppearance
void setTextAppearance (Context context, int resId)
Parameters | |
---|---|
context |
Context |
resId |
int |
setTextAppearanceResource
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
void setTextEndPadding (float textEndPadding)
Sets the end padding for this chip's text.
Related XML Attributes:
Parameters | |
---|---|
textEndPadding |
float : The end padding of this chip's text. |
setTextEndPaddingResource
void setTextEndPaddingResource (int id)
Sets the end padding for this chip's text using a resource id.
Related XML Attributes:
Parameters | |
---|---|
id |
int : The resource id for the end padding of this chip's text. |
setTextStartPadding
void setTextStartPadding (float textStartPadding)
Sets the start padding for this chip's text.
Related XML Attributes:
Parameters | |
---|---|
textStartPadding |
float : The start padding of this chip's text. |
setTextStartPaddingResource
void setTextStartPaddingResource (int id)
Sets the start padding for this chip's text using a resource id.
Related XML Attributes:
Parameters | |
---|---|
id |
int : The resource id for the start padding of this chip's text. |
shouldEnsureMinTouchTargetSize
boolean shouldEnsureMinTouchTargetSize ()
Returns whether this chip will expand its bounds (if needed) to meet the minimum touch target size.
Related XML Attributes:
Returns | |
---|---|
boolean |
See also:
Protected methods
dispatchHoverEvent
boolean dispatchHoverEvent (MotionEvent event)
Parameters | |
---|---|
event |
MotionEvent |
Returns | |
---|---|
boolean |
drawableStateChanged
void drawableStateChanged ()
onAttachedToWindow
void onAttachedToWindow ()
onCreateDrawableState
int[] onCreateDrawableState (int extraSpace)
Parameters | |
---|---|
extraSpace |
int |
Returns | |
---|---|
int[] |
onFocusChanged
void onFocusChanged (boolean focused, int direction, Rect previouslyFocusedRect)
Parameters | |
---|---|
focused |
boolean |
direction |
int |
previouslyFocusedRect |
Rect |
Content and code samples on this page are subject to the licenses described in the Content License. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2020-07-20 UTC.