ChipDrawable
public
class
ChipDrawable
extends MaterialShapeDrawable
implements
TintAwareDrawable,
Drawable.Callback
java.lang.Object | |||
↳ | android.graphics.drawable.Drawable | ||
↳ | com.google.android.material.shape.MaterialShapeDrawable | ||
↳ | com.google.android.material.chip.ChipDrawable |
ChipDrawable contains all the layout and draw logic for Chip
.
You can use ChipDrawable directly in contexts that require a Drawable. For example, an
auto-complete enabled EditText can replace snippets of text with a ChipDrawable to represent it
as a semantic entity. To create an instance of ChipDrawable, use createFromResource(Context, int)
and pass in an XML resource in this form:
<chip xmlns:app="http://schemas.android.com/apk/res-auto"
android:text="Hello, World!"/>
The basic attributes you can set are:
android:checkable
- If true, the chip can be toggled. If false, the chip acts like a button.android:text
- Sets the text of the chip.app:chipIcon
- Sets the icon of the chip, or use @null to display no icon. Usually on the left.app:checkedIcon
- Sets a custom icon to use when checked, or use @null to display no icon. Usually on the left.app:closeIcon
- Sets a custom icon that the user can click to close, or use @null to display no icon. Usually on the right.ellipsize
- Does not supportMARQUEE
because chip text should not scroll.
When used in this stand-alone mode, the host view must explicitly manage the ChipDrawable's state:
setBounds(int, int, int, int)
, taking into accountgetIntrinsicHeight()
andgetIntrinsicWidth()
.draw(Canvas)
setCallback(Callback)
, to support invalidations on the chip drawable or any of its child drawables. This includes animations.setState(int[])
, to support checking the chip, and touch/mouse/keyboard interactions on the chip.setCloseIconState(int[])
, to support touch, mouse, or keyboard interactions on the close icon.setHotspot(float, float)
setLayoutDirection(int)
, 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(int[])
.
See also:
Summary
Nested classes | |
---|---|
interface |
ChipDrawable.Delegate
Delegate interface to be implemented by Views that own a ChipDrawable. |
XML attributes | |
---|---|
Chip_checkedIcon |
|
Chip_checkedIconTint |
|
Chip_chipBackgroundColor |
|
Chip_chipCornerRadius |
|
Chip_chipEndPadding |
|
Chip_chipIconTint |
|
Chip_chipMinHeight |
|
Chip_chipStartPadding |
|
Chip_chipStrokeColor |
|
Chip_chipStrokeWidth |
|
Chip_closeIconEndPadding |
|
Chip_closeIconStartPadding |
|
Chip_hideMotionSpec |
|
Chip_iconEndPadding |
|
Chip_iconStartPadding |
|
Chip_rippleColor |
|
Chip_showMotionSpec |
|
Chip_textEndPadding |
|
Chip_textStartPadding |
Inherited constants |
---|
![]()
com.google.android.material.shape.MaterialShapeDrawable
|
Public methods | |
---|---|
static
ChipDrawable
|
createFromAttributes(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)
Returns a ChipDrawable from the given attributes. |
static
ChipDrawable
|
createFromResource(Context context, int id)
Returns a ChipDrawable from the given XML resource. |
void
|
draw(Canvas canvas)
|
int
|
getAlpha()
|
Drawable
|
getCheckedIcon()
Returns this chip's checked icon. |
ColorStateList
|
getCheckedIconTint()
Returns the |
ColorStateList
|
getChipBackgroundColor()
Returns this chip's background color. |
float
|
getChipCornerRadius()
Returns this chip's corner radius. |
float
|
getChipEndPadding()
Returns this chip's end padding. |
Drawable
|
getChipIcon()
|
float
|
getChipIconSize()
|
ColorStateList
|
getChipIconTint()
Returns the |
float
|
getChipMinHeight()
Returns this chip's minimum height. |
float
|
getChipStartPadding()
Returns this chip's start padding. |
ColorStateList
|
getChipStrokeColor()
Returns this chip's stroke color. |
float
|
getChipStrokeWidth()
Returns this chip's stroke width. |
void
|
getChipTouchBounds(RectF bounds)
Returns the chip's ChipDrawable-absolute bounds (top-left is |
Drawable
|
getCloseIcon()
|
CharSequence
|
getCloseIconContentDescription()
|
float
|
getCloseIconEndPadding()
Returns the end padding for this chip's close icon. |
float
|
getCloseIconSize()
|
float
|
getCloseIconStartPadding()
Returns the start padding for this chip's close icon. |
int[]
|
getCloseIconState()
Describes the current state of the close icon. |
ColorStateList
|
getCloseIconTint()
|
void
|
getCloseIconTouchBounds(RectF bounds)
Returns the close icon's ChipDrawable-absolute bounds (top-left is |
ColorFilter
|
getColorFilter()
|
TextUtils.TruncateAt
|
getEllipsize()
|
MotionSpec
|
getHideMotionSpec()
Returns this chip's hide motion spec. |
float
|
getIconEndPadding()
Returns the end padding for this chip's icon. |
float
|
getIconStartPadding()
Returns the start padding for this chip's icon. |
int
|
getIntrinsicHeight()
Returns the height at which the chip would like to be laid out. |
int
|
getIntrinsicWidth()
Returns the width at which the chip would like to be laid out. |
int
|
getMaxWidth()
Returns the maximum width of TextView in terms of pixels. |
int
|
getOpacity()
|
void
|
getOutline(Outline outline)
|
ColorStateList
|
getRippleColor()
Returns this chip's ripple color. |
MotionSpec
|
getShowMotionSpec()
Returns this chip's show motion spec. |
CharSequence
|
getText()
|
TextAppearance
|
getTextAppearance()
|
float
|
getTextEndPadding()
Returns the end padding for this chip's text. |
float
|
getTextStartPadding()
Returns the start padding for this chip's text. |
boolean
|
getUseCompatRipple()
Returns whether this ChipDrawable should draw its own compatibility ripples. |
void
|
invalidateDrawable(Drawable who)
|
boolean
|
isCheckable()
|
boolean
|
isCheckedIconEnabled()
This method is deprecated.
Use |
boolean
|
isCheckedIconVisible()
|
boolean
|
isChipIconEnabled()
This method is deprecated.
Use |
boolean
|
isChipIconVisible()
|
boolean
|
isCloseIconEnabled()
This method is deprecated.
Use |
boolean
|
isCloseIconStateful()
Indicates whether the close icon drawable will change its appearance based on state. |
boolean
|
isCloseIconVisible()
|
boolean
|
isStateful()
Indicates whether this chip drawable will change its appearance based on state. |
boolean
|
onLayoutDirectionChanged(int layoutDirection)
|
boolean
|
onStateChange(int[] state)
|
void
|
onTextSizeChange()
|
void
|
scheduleDrawable(Drawable who, Runnable what, long when)
|
void
|
setAlpha(int alpha)
Sets the alpha of this ChipDrawable. |
void
|
setCheckable(boolean checkable)
|
void
|
setCheckableResource(int id)
|
void
|
setCheckedIcon(Drawable checkedIcon)
Sets this chip's checked icon. |
void
|
setCheckedIconEnabled(boolean checkedIconEnabled)
This method is deprecated.
Use |
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 the checked icon's color tint using the specified |
void
|
setCheckedIconTintResource(int id)
Sets the checked icon's color tint using a resource ID. |
void
|
setCheckedIconVisible(int id)
|
void
|
setCheckedIconVisible(boolean checkedIconVisible)
|
void
|
setChipBackgroundColor(ColorStateList chipBackgroundColor)
Sets this chip's background color. |
void
|
setChipBackgroundColorResource(int id)
Sets this chip's background color using a resource id. |
void
|
setChipCornerRadius(float chipCornerRadius)
This method is deprecated.
call |
void
|
setChipCornerRadiusResource(int id)
This method is deprecated.
call |
void
|
setChipEndPadding(float chipEndPadding)
Sets this chip's end padding. |
void
|
setChipEndPaddingResource(int id)
Sets this chip's end padding using a resource id. |
void
|
setChipIcon(Drawable chipIcon)
|
void
|
setChipIconEnabled(boolean chipIconEnabled)
This method is deprecated.
Use |
void
|
setChipIconEnabledResource(int id)
This method is deprecated.
Use |
void
|
setChipIconResource(int id)
|
void
|
setChipIconSize(float chipIconSize)
|
void
|
setChipIconSizeResource(int id)
|
void
|
setChipIconTint(ColorStateList chipIconTint)
Sets the chip icon's color tint using the specified |
void
|
setChipIconTintResource(int id)
Sets the chip icon's color tint using a resource ID. |
void
|
setChipIconVisible(int id)
|
void
|
setChipIconVisible(boolean chipIconVisible)
|
void
|
setChipMinHeight(float chipMinHeight)
Sets this chip's minimum height. |
void
|
setChipMinHeightResource(int id)
Sets this chip's minimum height using a resource id. |
void
|
setChipStartPadding(float chipStartPadding)
Sets this chip's start padding. |
void
|
setChipStartPaddingResource(int id)
Sets this chip's start padding using a resource id. |
void
|
setChipStrokeColor(ColorStateList chipStrokeColor)
Sets this chip's stroke color. |
void
|
setChipStrokeColorResource(int id)
Sets this chip's stroke color using a resource id. |
void
|
setChipStrokeWidth(float chipStrokeWidth)
Sets this chip's stroke width. |
void
|
setChipStrokeWidthResource(int id)
Sets this chip's stroke width using a resource id. |
void
|
setCloseIcon(Drawable closeIcon)
|
void
|
setCloseIconContentDescription(CharSequence closeIconContentDescription)
|
void
|
setCloseIconEnabled(boolean closeIconEnabled)
This method is deprecated.
Use |
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)
|
void
|
setCloseIconSize(float closeIconSize)
|
void
|
setCloseIconSizeResource(int id)
|
void
|
setCloseIconStartPadding(float closeIconStartPadding)
Sets the start padding for this chip's close icon. |
void
|
setCloseIconStartPaddingResource(int id)
Sets the start padding for this chip's close icon using a resource id. |
boolean
|
setCloseIconState(int[] stateSet)
Specify a set of states for the close icon. |
void
|
setCloseIconTint(ColorStateList closeIconTint)
|
void
|
setCloseIconTintResource(int id)
|
void
|
setCloseIconVisible(boolean closeIconVisible)
|
void
|
setCloseIconVisible(int id)
|
void
|
setColorFilter(ColorFilter colorFilter)
|
void
|
setDelegate(ChipDrawable.Delegate delegate)
Sets the View delegate that owns this ChipDrawable. |
void
|
setEllipsize(TextUtils.TruncateAt truncateAt)
|
void
|
setHideMotionSpec(MotionSpec hideMotionSpec)
Sets this chip's hide motion spec. |
void
|
setHideMotionSpecResource(int id)
Sets this chip's hide motion spec using a resource id. |
void
|
setIconEndPadding(float iconEndPadding)
Sets the end padding for this chip's icon. |
void
|
setIconEndPaddingResource(int id)
Sets the end padding for this chip's icon using a resource id. |
void
|
setIconStartPadding(float iconStartPadding)
Sets this chip's icon start padding. |
void
|
setIconStartPaddingResource(int id)
Sets the start padding for this chip's icon using a resource id. |
void
|
setMaxWidth(int maxWidth)
Sets the width of the TextView to be exactly |
void
|
setRippleColor(ColorStateList rippleColor)
Sets this chip's ripple color. |
void
|
setRippleColorResource(int id)
Sets this chip's ripple color using a resource id. |
void
|
setShowMotionSpec(MotionSpec showMotionSpec)
Sets this chip's show motion spec. |
void
|
setShowMotionSpecResource(int id)
Sets this chip's show motion spec using a resource id. |
void
|
setText(CharSequence text)
|
void
|
setTextAppearance(TextAppearance textAppearance)
|
void
|
setTextAppearanceResource(int id)
|
void
|
setTextEndPadding(float textEndPadding)
Sets the end padding for this chip's text. |
void
|
setTextEndPaddingResource(int id)
Sets the end padding for this chip's text using a resource id. |
void
|
setTextResource(int id)
|
void
|
setTextStartPadding(float textStartPadding)
Sets the start padding for this chip's text. |
void
|
setTextStartPaddingResource(int id)
Sets the start padding for this chip's text using a resource id. |
void
|
setTintList(ColorStateList tint)
|
void
|
setTintMode(PorterDuff.Mode tintMode)
|
void
|
setUseCompatRipple(boolean useCompatRipple)
Sets whether this ChipDrawable should draw its own compatibility ripples. |
boolean
|
setVisible(boolean visible, boolean restart)
|
void
|
unscheduleDrawable(Drawable who, Runnable what)
|
Protected methods | |
---|---|
boolean
|
onLevelChange(int level)
|
void
|
onSizeChange()
Attempts to call |
Inherited methods | |
---|---|
![]()
com.google.android.material.shape.MaterialShapeDrawable
| |
![]()
android.graphics.drawable.Drawable
| |
![]()
java.lang.Object
| |
![]()
androidx.core.graphics.drawable.TintAwareDrawable
| |
![]()
com.google.android.material.shape.Shapeable
| |
![]()
android.graphics.drawable.Drawable.Callback
|
XML attributes
Chip_checkedIcon
Related methods:
Chip_checkedIconTint
Related methods:
Chip_chipBackgroundColor
Related methods:
Chip_chipCornerRadius
Related methods:
Chip_chipEndPadding
Related methods:
Chip_chipIconTint
Related methods:
Chip_chipMinHeight
Related methods:
Chip_chipStartPadding
Related methods:
Chip_chipStrokeColor
Related methods:
Chip_chipStrokeWidth
Related methods:
Chip_closeIconEndPadding
Related methods:
Chip_closeIconStartPadding
Related methods:
Chip_hideMotionSpec
Related methods:
Chip_iconEndPadding
Related methods:
Chip_iconStartPadding
Related methods:
Chip_rippleColor
Related methods:
Chip_showMotionSpec
Related methods:
Chip_textEndPadding
Related methods:
Chip_textStartPadding
Related methods:
Public methods
createFromAttributes
ChipDrawable createFromAttributes (Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)
Returns a ChipDrawable from the given attributes.
Parameters | |
---|---|
context |
Context |
attrs |
AttributeSet |
defStyleAttr |
int |
defStyleRes |
int |
Returns | |
---|---|
ChipDrawable |
createFromResource
ChipDrawable createFromResource (Context context, int id)
Returns a ChipDrawable from the given XML resource. All attributes from Chip
and a custom style
attribute are supported. A chip resource may
look like:
<chip
xmlns:app="http://schemas.android.com/apk/res-auto"
style="@style/Widget.MaterialComponents.Chip.Entry"
app:chipIcon="@drawable/custom_icon"/>
Parameters | |
---|---|
context |
Context |
id |
int |
Returns | |
---|---|
ChipDrawable |
draw
void draw (Canvas canvas)
Parameters | |
---|---|
canvas |
Canvas |
getAlpha
int getAlpha ()
Returns | |
---|---|
int |
getCheckedIcon
Drawable getCheckedIcon ()
Returns this chip's checked icon.
Related XML Attributes:
Returns | |
---|---|
Drawable |
See also:
getCheckedIconTint
ColorStateList getCheckedIconTint ()
Returns the ColorStateList
used to tint the checked icon.
Returns | |
---|---|
ColorStateList |
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:
getChipEndPadding
float getChipEndPadding ()
Returns this chip's end padding.
Related XML Attributes:
Returns | |
---|---|
float |
See also:
getChipIcon
Drawable getChipIcon ()
Returns | |
---|---|
Drawable |
getChipIconSize
float getChipIconSize ()
Returns | |
---|---|
float |
getChipIconTint
ColorStateList getChipIconTint ()
Returns the ColorStateList
used to tint the chip icon.
Returns | |
---|---|
ColorStateList |
getChipMinHeight
float getChipMinHeight ()
Returns this chip's minimum height.
Related XML Attributes:
Returns | |
---|---|
float |
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:
getChipTouchBounds
void getChipTouchBounds (RectF bounds)
Returns the chip's ChipDrawable-absolute bounds (top-left is
[ChipDrawable.getBounds().left, ChipDrawable.getBounds().top]
).
Parameters | |
---|---|
bounds |
RectF |
getCloseIcon
Drawable getCloseIcon ()
Returns | |
---|---|
Drawable |
getCloseIconContentDescription
CharSequence getCloseIconContentDescription ()
Returns | |
---|---|
CharSequence |
getCloseIconEndPadding
float getCloseIconEndPadding ()
Returns the end padding for this chip's close icon.
Related XML Attributes:
Returns | |
---|---|
float |
See also:
getCloseIconSize
float getCloseIconSize ()
Returns | |
---|---|
float |
getCloseIconStartPadding
float getCloseIconStartPadding ()
Returns the start padding for this chip's close icon.
Related XML Attributes:
Returns | |
---|---|
float |
See also:
getCloseIconState
int[] getCloseIconState ()
Describes the current state of the close icon.
Returns | |
---|---|
int[] |
getCloseIconTint
ColorStateList getCloseIconTint ()
Returns | |
---|---|
ColorStateList |
getCloseIconTouchBounds
void getCloseIconTouchBounds (RectF bounds)
Returns the close icon's ChipDrawable-absolute bounds (top-left is
[ChipDrawable.getBounds().left, ChipDrawable.getBounds().top]
).
Parameters | |
---|---|
bounds |
RectF |
getColorFilter
ColorFilter getColorFilter ()
Returns | |
---|---|
ColorFilter |
getEllipsize
TextUtils.TruncateAt getEllipsize ()
Returns | |
---|---|
TextUtils.TruncateAt |
getHideMotionSpec
MotionSpec getHideMotionSpec ()
Returns this chip's hide motion spec.
Related XML Attributes:
Returns | |
---|---|
MotionSpec |
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:
getIntrinsicHeight
int getIntrinsicHeight ()
Returns the height at which the chip would like to be laid out.
Returns | |
---|---|
int |
getIntrinsicWidth
int getIntrinsicWidth ()
Returns the width at which the chip would like to be laid out.
Returns | |
---|---|
int |
getMaxWidth
int getMaxWidth ()
Returns the maximum width of TextView in terms of pixels.
Returns | |
---|---|
int |
See also:
getOpacity
int getOpacity ()
Returns | |
---|---|
int |
getOutline
void getOutline (Outline outline)
Parameters | |
---|---|
outline |
Outline |
getRippleColor
ColorStateList getRippleColor ()
Returns this chip's ripple color.
Related XML Attributes:
Returns | |
---|---|
ColorStateList |
See also:
getShowMotionSpec
MotionSpec getShowMotionSpec ()
Returns this chip's show motion spec.
Related XML Attributes:
Returns | |
---|---|
MotionSpec |
See also:
getText
CharSequence getText ()
Returns | |
---|---|
CharSequence |
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:
getUseCompatRipple
boolean getUseCompatRipple ()
Returns whether this ChipDrawable should draw its own compatibility ripples.
Returns | |
---|---|
boolean |
invalidateDrawable
void invalidateDrawable (Drawable who)
Parameters | |
---|---|
who |
Drawable |
isCheckable
boolean isCheckable ()
Returns | |
---|---|
boolean |
isCheckedIconEnabled
boolean isCheckedIconEnabled ()
This method is deprecated.
Use isCheckedIconVisible()
instead.
Returns | |
---|---|
boolean |
isCheckedIconVisible
boolean isCheckedIconVisible ()
Returns | |
---|---|
boolean |
isChipIconEnabled
boolean isChipIconEnabled ()
This method is deprecated.
Use isChipIconVisible()
instead.
Returns | |
---|---|
boolean |
isChipIconVisible
boolean isChipIconVisible ()
Returns | |
---|---|
boolean |
isCloseIconEnabled
boolean isCloseIconEnabled ()
This method is deprecated.
Use isCloseIconVisible()
instead.
Returns | |
---|---|
boolean |
isCloseIconStateful
boolean isCloseIconStateful ()
Indicates whether the close icon drawable will change its appearance based on state.
Returns | |
---|---|
boolean |
isCloseIconVisible
boolean isCloseIconVisible ()
Returns | |
---|---|
boolean |
isStateful
boolean isStateful ()
Indicates whether this chip drawable will change its appearance based on state.
Returns | |
---|---|
boolean |
onLayoutDirectionChanged
boolean onLayoutDirectionChanged (int layoutDirection)
Parameters | |
---|---|
layoutDirection |
int |
Returns | |
---|---|
boolean |
onStateChange
boolean onStateChange (int[] state)
Parameters | |
---|---|
state |
int |
Returns | |
---|---|
boolean |
onTextSizeChange
void onTextSizeChange ()
scheduleDrawable
void scheduleDrawable (Drawable who, Runnable what, long when)
Parameters | |
---|---|
who |
Drawable |
what |
Runnable |
when |
long |
setAlpha
void setAlpha (int alpha)
Sets the alpha of this ChipDrawable. This will drastically decrease draw performance. You are
highly encouraged to use setAlpha(float)
instead.
Parameters | |
---|---|
alpha |
int |
setCheckable
void setCheckable (boolean checkable)
Parameters | |
---|---|
checkable |
boolean |
setCheckableResource
void setCheckableResource (int id)
Parameters | |
---|---|
id |
int |
setCheckedIcon
void setCheckedIcon (Drawable checkedIcon)
Sets this chip's checked icon.
Related XML Attributes:
Parameters | |
---|---|
checkedIcon |
Drawable : This chip's checked icon. |
setCheckedIconEnabled
void setCheckedIconEnabled (boolean checkedIconEnabled)
This method is deprecated.
Use setCheckedIconVisible(boolean)
instead.
Parameters | |
---|---|
checkedIconEnabled |
boolean |
setCheckedIconEnabledResource
void setCheckedIconEnabledResource (int id)
This method is deprecated.
Use setCheckedIconVisible(int)
instead.
Parameters | |
---|---|
id |
int |
setCheckedIconResource
void setCheckedIconResource (int id)
Sets this chip's checked icon using a resource id.
Related XML Attributes:
Parameters | |
---|---|
id |
int : The resource id of this chip's checked icon. |
setCheckedIconTint
void setCheckedIconTint (ColorStateList checkedIconTint)
Sets the checked icon's color tint using the specified ColorStateList
.
Related XML Attributes:
Parameters | |
---|---|
checkedIconTint |
ColorStateList : ColorStateList to tint the checked icon. |
setCheckedIconTintResource
void setCheckedIconTintResource (int id)
Sets the checked icon's color tint using a resource ID.
Related XML Attributes:
Parameters | |
---|---|
id |
int : Resource id of a ColorStateList to tint the checked icon. |
setCheckedIconVisible
void setCheckedIconVisible (int id)
Parameters | |
---|---|
id |
int |
setCheckedIconVisible
void setCheckedIconVisible (boolean checkedIconVisible)
Parameters | |
---|---|
checkedIconVisible |
boolean |
setChipBackgroundColor
void setChipBackgroundColor (ColorStateList chipBackgroundColor)
Sets this chip's background color.
Related XML Attributes:
Parameters | |
---|---|
chipBackgroundColor |
ColorStateList : This chip's background color. |
setChipBackgroundColorResource
void setChipBackgroundColorResource (int id)
Sets this chip's background color using a resource id.
Related XML Attributes:
Parameters | |
---|---|
id |
int : The resource id of this chip's background color. |
setChipCornerRadius
void setChipCornerRadius (float chipCornerRadius)
This method is deprecated.
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 |
setChipEndPadding
void setChipEndPadding (float chipEndPadding)
Sets this chip's end padding.
Related XML Attributes:
Parameters | |
---|---|
chipEndPadding |
float : This chip's end padding. |
setChipEndPaddingResource
void setChipEndPaddingResource (int id)
Sets this chip's end padding using a resource id.
Related XML Attributes:
Parameters | |
---|---|
id |
int : The resource id for this chip's end padding. |
setChipIcon
void setChipIcon (Drawable chipIcon)
Parameters | |
---|---|
chipIcon |
Drawable |
setChipIconEnabled
void setChipIconEnabled (boolean chipIconEnabled)
This method is deprecated.
Use setChipIconVisible(boolean)
instead.
Parameters | |
---|---|
chipIconEnabled |
boolean |
setChipIconEnabledResource
void setChipIconEnabledResource (int id)
This method is deprecated.
Use setChipIconVisible(int)
instead.
Parameters | |
---|---|
id |
int |
setChipIconResource
void setChipIconResource (int id)
Parameters | |
---|---|
id |
int |
setChipIconSize
void setChipIconSize (float chipIconSize)
Parameters | |
---|---|
chipIconSize |
float |
setChipIconSizeResource
void setChipIconSizeResource (int id)
Parameters | |
---|---|
id |
int |
setChipIconTint
void setChipIconTint (ColorStateList chipIconTint)
Sets the chip icon's color tint using the specified ColorStateList
.
Related XML Attributes:
Parameters | |
---|---|
chipIconTint |
ColorStateList : ColorStateList to tint the chip icon. |
setChipIconTintResource
void setChipIconTintResource (int id)
Sets the chip icon's color tint using a resource ID.
Related XML Attributes:
Parameters | |
---|---|
id |
int : Resource id of a ColorStateList to tint the chip icon. |
setChipIconVisible
void setChipIconVisible (int id)
Parameters | |
---|---|
id |
int |
setChipIconVisible
void setChipIconVisible (boolean chipIconVisible)
Parameters | |
---|---|
chipIconVisible |
boolean |
setChipMinHeight
void setChipMinHeight (float chipMinHeight)
Sets this chip's minimum height.
Related XML Attributes:
Parameters | |
---|---|
chipMinHeight |
float : This chip's mininum height. |
setChipMinHeightResource
void setChipMinHeightResource (int id)
Sets this chip's minimum height using a resource id.
Related XML Attributes:
Parameters | |
---|---|
id |
int : The resource id of this chip's mininum height. |
setChipStartPadding
void setChipStartPadding (float chipStartPadding)
Sets this chip's start padding.
Related XML Attributes:
Parameters | |
---|---|
chipStartPadding |
float : This chip's start padding. |
setChipStartPaddingResource
void setChipStartPaddingResource (int id)
Sets this chip's start padding using a resource id.
Related XML Attributes:
Parameters | |
---|---|
id |
int : The resource id of this chip's start padding. |
setChipStrokeColor
void setChipStrokeColor (ColorStateList chipStrokeColor)
Sets this chip's stroke color.
Related XML Attributes:
Parameters | |
---|---|
chipStrokeColor |
ColorStateList : This chip's stroke color. |
setChipStrokeColorResource
void setChipStrokeColorResource (int id)
Sets this chip's stroke color using a resource id.
Related XML Attributes:
Parameters | |
---|---|
id |
int : The resource id of this chip's stroke color. |
setChipStrokeWidth
void setChipStrokeWidth (float chipStrokeWidth)
Sets this chip's stroke width.
Related XML Attributes:
Parameters | |
---|---|
chipStrokeWidth |
float : This chip's stroke width. |
setChipStrokeWidthResource
void setChipStrokeWidthResource (int id)
Sets this chip's stroke width using a resource id.
Related XML Attributes:
Parameters | |
---|---|
id |
int : The resource id of this chip's stroke width. |
setCloseIcon
void setCloseIcon (Drawable closeIcon)
Parameters | |
---|---|
closeIcon |
Drawable |
setCloseIconContentDescription
void setCloseIconContentDescription (CharSequence closeIconContentDescription)
Parameters | |
---|---|
closeIconContentDescription |
CharSequence |
setCloseIconEnabled
void setCloseIconEnabled (boolean closeIconEnabled)
This method is deprecated.
Use setCloseIconVisible(int)
instead.
Parameters | |
---|---|
closeIconEnabled |
boolean |
setCloseIconEnabledResource
void setCloseIconEnabledResource (int id)
This method is deprecated.
Use setCloseIconVisible(int)
instead.
Parameters | |
---|---|
id |
int |
setCloseIconEndPadding
void setCloseIconEndPadding (float closeIconEndPadding)
Sets the end padding for this chip's close icon.
Related XML Attributes:
Parameters | |
---|---|
closeIconEndPadding |
float : The end padding of this chip's close icon. |
setCloseIconEndPaddingResource
void setCloseIconEndPaddingResource (int id)
Sets the end padding for this chip's close icon using a resource id.
Related XML Attributes:
Parameters | |
---|---|
id |
int : The resource id for the end padding of this chip's close icon. |
setCloseIconResource
void setCloseIconResource (int id)
Parameters | |
---|---|
id |
int |
setCloseIconSize
void setCloseIconSize (float closeIconSize)
Parameters | |
---|---|
closeIconSize |
float |
setCloseIconSizeResource
void setCloseIconSizeResource (int id)
Parameters | |
---|---|
id |
int |
setCloseIconStartPadding
void setCloseIconStartPadding (float closeIconStartPadding)
Sets the start padding for this chip's close icon.
Related XML Attributes:
Parameters | |
---|---|
closeIconStartPadding |
float : The start padding of this chip's close icon. |
setCloseIconStartPaddingResource
void setCloseIconStartPaddingResource (int id)
Sets the start padding for this chip's close icon using a resource id.
Related XML Attributes:
Parameters | |
---|---|
id |
int : The resource id for the start padding of this chip's close icon. |
setCloseIconState
boolean setCloseIconState (int[] stateSet)
Specify a set of states for the close icon. This is a separate state set than the one used for the rest of the chip.
Parameters | |
---|---|
stateSet |
int |
Returns | |
---|---|
boolean |
setCloseIconTint
void setCloseIconTint (ColorStateList closeIconTint)
Parameters | |
---|---|
closeIconTint |
ColorStateList |
setCloseIconTintResource
void setCloseIconTintResource (int id)
Parameters | |
---|---|
id |
int |
setCloseIconVisible
void setCloseIconVisible (boolean closeIconVisible)
Parameters | |
---|---|
closeIconVisible |
boolean |
setCloseIconVisible
void setCloseIconVisible (int id)
Parameters | |
---|---|
id |
int |
setColorFilter
void setColorFilter (ColorFilter colorFilter)
Parameters | |
---|---|
colorFilter |
ColorFilter |
setDelegate
void setDelegate (ChipDrawable.Delegate delegate)
Sets the View delegate that owns this ChipDrawable.
Parameters | |
---|---|
delegate |
ChipDrawable.Delegate |
setEllipsize
void setEllipsize (TextUtils.TruncateAt truncateAt)
Parameters | |
---|---|
truncateAt |
TextUtils.TruncateAt |
setHideMotionSpec
void setHideMotionSpec (MotionSpec hideMotionSpec)
Sets this chip's hide motion spec.
Related XML Attributes:
Parameters | |
---|---|
hideMotionSpec |
MotionSpec : This chip's hide motion spec. |
setHideMotionSpecResource
void setHideMotionSpecResource (int id)
Sets this chip's hide motion spec using a resource id.
Related XML Attributes:
Parameters | |
---|---|
id |
int : The resource id of this chip's hide motion spec. |
setIconEndPadding
void setIconEndPadding (float iconEndPadding)
Sets the end padding for this chip's icon.
Related XML Attributes:
Parameters | |
---|---|
iconEndPadding |
float : The end padding of this chip's icon. |
setIconEndPaddingResource
void setIconEndPaddingResource (int id)
Sets the end padding for this chip's icon using a resource id.
Related XML Attributes:
Parameters | |
---|---|
id |
int : The resource id for the end padding of this chip's icon. |
setIconStartPadding
void setIconStartPadding (float iconStartPadding)
Sets this chip's icon start padding.
Related XML Attributes:
Parameters | |
---|---|
iconStartPadding |
float : The start padding of this chip's icon. |
setIconStartPaddingResource
void setIconStartPaddingResource (int id)
Sets the start padding for this chip's icon using a resource id.
Related XML Attributes:
Parameters | |
---|---|
id |
int : The resource id for the start padding of this chip's icon. |
setMaxWidth
void setMaxWidth (int maxWidth)
Sets the width of the TextView to be exactly pixels
wide.
Parameters | |
---|---|
maxWidth |
int : maximum width of the textview.
|
setRippleColor
void setRippleColor (ColorStateList rippleColor)
Sets this chip's ripple color.
Related XML Attributes:
Parameters | |
---|---|
rippleColor |
ColorStateList : This chip's ripple color. |
setRippleColorResource
void setRippleColorResource (int id)
Sets this chip's ripple color using a resource id.
Related XML Attributes:
Parameters | |
---|---|
id |
int : The resource id of this chip's ripple color. |
setShowMotionSpec
void setShowMotionSpec (MotionSpec showMotionSpec)
Sets this chip's show motion spec.
Related XML Attributes:
Parameters | |
---|---|
showMotionSpec |
MotionSpec : This chip's show motion spec. |
setShowMotionSpecResource
void setShowMotionSpecResource (int id)
Sets this chip's show motion spec using a resource id.
Related XML Attributes:
Parameters | |
---|---|
id |
int : The resource id of this chip's show motion spec. |
setText
void setText (CharSequence text)
Parameters | |
---|---|
text |
CharSequence |
setTextAppearance
void setTextAppearance (TextAppearance textAppearance)
Parameters | |
---|---|
textAppearance |
TextAppearance |
setTextAppearanceResource
void setTextAppearanceResource (int id)
Parameters | |
---|---|
id |
int |
setTextEndPadding
void setTextEndPadding (float textEndPadding)
Sets the end padding for this chip's text.
Related XML Attributes:
Parameters | |
---|---|
textEndPadding |
float : The end padding of this chip's text. |
setTextEndPaddingResource
void setTextEndPaddingResource (int id)
Sets the end padding for this chip's text using a resource id.
Related XML Attributes:
Parameters | |
---|---|
id |
int : The resource id for the end padding of this chip's text. |
setTextResource
void setTextResource (int id)
Parameters | |
---|---|
id |
int |
setTextStartPadding
void setTextStartPadding (float textStartPadding)
Sets the start padding for this chip's text.
Related XML Attributes:
Parameters | |
---|---|
textStartPadding |
float : The start padding of this chip's text. |
setTextStartPaddingResource
void setTextStartPaddingResource (int id)
Sets the start padding for this chip's text using a resource id.
Related XML Attributes:
Parameters | |
---|---|
id |
int : The resource id for the start padding of this chip's text. |
setTintList
void setTintList (ColorStateList tint)
Parameters | |
---|---|
tint |
ColorStateList |
setTintMode
void setTintMode (PorterDuff.Mode tintMode)
Parameters | |
---|---|
tintMode |
PorterDuff.Mode |
setUseCompatRipple
void setUseCompatRipple (boolean useCompatRipple)
Sets whether this ChipDrawable should draw its own compatibility ripples.
Parameters | |
---|---|
useCompatRipple |
boolean |
setVisible
boolean setVisible (boolean visible, boolean restart)
Parameters | |
---|---|
visible |
boolean |
restart |
boolean |
Returns | |
---|---|
boolean |
unscheduleDrawable
void unscheduleDrawable (Drawable who, Runnable what)
Parameters | |
---|---|
who |
Drawable |
what |
Runnable |
Protected methods
onLevelChange
boolean onLevelChange (int level)
Parameters | |
---|---|
level |
int |
Returns | |
---|---|
boolean |
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.