public class RippleDrawableICS extends LayerDrawable implements RippleDrawable
setHotspot(float, float) with the corresponding state
attribute identifier.
A touch feedback drawable may contain multiple child layers, including a
special mask layer that is not drawn to the screen. A single layer may be
set as the mask from XML by specifying its android:id value as
R.id.mask. At run time, a single layer may be set as the
mask using setId(..., R.id.carbon_mask) or an existing mask layer
may be replaced using setDrawableByLayerId(R.id.carbon_mask, ...).
<!-- A red ripple masked against an opaque rectangle. --/>
<ripple android:color="#ffff0000">
<item android:id="@android:id/mask"
android:drawable="@android:color/white" />
</ripple>
If a mask layer is set, the ripple effect will be masked against that layer
before it is drawn over the composite of the remaining child layers.
If no mask layer is set, the ripple effect is masked against the composite
of the child layers.
<!-- A green ripple drawn atop a black rectangle. --/>
<ripple android:color="#ff00ff00">
<item android:drawable="@android:color/black" />
</ripple>
<!-- A blue ripple drawn atop a drawable resource. --/>
<ripple android:color="#ff0000ff">
<item android:drawable="@drawable/my_drawable" />
</ripple>
If no child layers or mask is specified and the ripple is set as a View
background, the ripple will be drawn atop the first available parent
background within the View's hierarchy. In this case, the drawing region
may extend outside of the Drawable bounds.
<!-- An unbounded red ripple. --/>
<ripple android:color="#ffff0000" />
android.graphics.drawable.Drawable.Callback, android.graphics.drawable.Drawable.ConstantStateRippleDrawable.Style| Modifier and Type | Field and Description |
|---|---|
static int |
RADIUS_AUTO
Radius value that specifies the ripple radius should be computed based
on the size of the ripple's container.
|
PADDING_MODE_NEST, PADDING_MODE_STACK| Constructor and Description |
|---|
RippleDrawableICS(android.content.res.ColorStateList color,
android.graphics.drawable.Drawable content,
android.graphics.drawable.Drawable mask)
Creates a new ripple drawable with the specified ripple color and
optional content and mask drawables.
|
RippleDrawableICS(android.content.res.ColorStateList color,
android.graphics.drawable.Drawable background,
RippleDrawable.Style style) |
| Modifier and Type | Method and Description |
|---|---|
void |
applyTheme(android.content.res.Resources.Theme t)
Applies the specified theme to this Drawable and its children.
|
boolean |
canApplyTheme() |
void |
draw(android.graphics.Canvas canvas)
Optimized for drawing ripples with a mask layer and optional content.
|
int |
getAlpha()
Gets the current alpha value for the drawable. 0 means fully transparent,
255 means fully opaque.
|
android.graphics.drawable.Drawable |
getBackground() |
android.content.res.ColorStateList |
getColor() |
android.graphics.drawable.Drawable.ConstantState |
getConstantState() |
android.graphics.Rect |
getDirtyBounds() |
void |
getHotspotBounds(android.graphics.Rect outRect) |
int |
getOpacity() |
void |
getOutline(android.graphics.Outline outline)
Populates
outline with the first available layer outline,
excluding the mask layer. |
int |
getRadius() |
RippleDrawable.Style |
getStyle() |
void |
inflate(android.content.res.Resources r,
org.xmlpull.v1.XmlPullParser parser,
android.util.AttributeSet attrs,
android.content.res.Resources.Theme theme)
Inflate this Drawable from an XML resource optionally styled by a theme.
|
void |
invalidateSelf() |
boolean |
isHotspotEnabled() |
boolean |
isStateful() |
void |
jumpToCurrentState() |
android.graphics.drawable.Drawable |
mutate() |
protected void |
onBoundsChange(android.graphics.Rect bounds) |
protected boolean |
onStateChange(int[] stateSet) |
void |
setColor(android.content.res.ColorStateList color)
Sets the ripple color.
|
boolean |
setDrawableByLayerId(int id,
android.graphics.drawable.Drawable drawable)
Replaces the
Drawable for the layer with the given id. |
void |
setHotspot(float x,
float y)
Specifies the hotspot's location within the drawable.
|
void |
setHotspotBounds(int left,
int top,
int right,
int bottom)
Sets the bounds to which the hotspot is constrained, if they should be
different from the drawable bounds.
|
void |
setHotspotEnabled(boolean useHotspot) |
void |
setPaddingMode(int mode)
Specifies how layer padding should affect the bounds of subsequent
layers.
|
void |
setRadius(int radius)
Sets the radius in pixels of the fully expanded ripple.
|
boolean |
setVisible(boolean visible,
boolean restart) |
addLayer, findDrawableByLayerId, findIndexByLayerId, getBottomPadding, getChangingConfigurations, getDrawable, getEndPadding, getId, getIntrinsicHeight, getIntrinsicWidth, getLayerGravity, getLayerHeight, getLayerInsetBottom, getLayerInsetEnd, getLayerInsetLeft, getLayerInsetRight, getLayerInsetStart, getLayerInsetTop, getLayerWidth, getLeftPadding, getNumberOfLayers, getPadding, getPaddingMode, getRightPadding, getStartPadding, getTopPadding, invalidateDrawable, isAutoMirrored, onLayoutDirectionChanged, onLevelChange, scheduleDrawable, setAlpha, setAutoMirrored, setColorFilter, setDither, setDrawable, setId, setLayerGravity, setLayerHeight, setLayerInset, setLayerInsetBottom, setLayerInsetEnd, setLayerInsetLeft, setLayerInsetRelative, setLayerInsetRight, setLayerInsetStart, setLayerInsetTop, setLayerSize, setLayerWidth, setOpacity, setPadding, setPaddingRelative, setTintList, setTintMode, unscheduleDrawablegetColorFilter, setTintclearColorFilter, copyBounds, copyBounds, createFromPath, createFromResourceStream, createFromResourceStream, createFromStream, createFromXml, createFromXml, createFromXmlInner, createFromXmlInner, getBounds, getCallback, getCurrent, getLayoutDirection, getLevel, getMinimumHeight, getMinimumWidth, getState, getTransparentRegion, inflate, isFilterBitmap, isVisible, resolveOpacity, scheduleSelf, setBounds, setBounds, setCallback, setChangingConfigurations, setColorFilter, setFilterBitmap, setLayoutDirection, setLevel, setState, unscheduleSelfclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitsetAlpha, setBounds, setBounds, setCallback, setColorFilter, setStatepublic static final int RADIUS_AUTO
public RippleDrawableICS(android.content.res.ColorStateList color,
android.graphics.drawable.Drawable background,
RippleDrawable.Style style)
public RippleDrawableICS(@NonNull
android.content.res.ColorStateList color,
@Nullable
android.graphics.drawable.Drawable content,
@Nullable
android.graphics.drawable.Drawable mask)
color - The ripple colorcontent - The content drawable, may be nullmask - The mask drawable, may be nullpublic void jumpToCurrentState()
jumpToCurrentState in interface RippleDrawablejumpToCurrentState in class android.graphics.drawable.Drawablepublic int getOpacity()
getOpacity in interface RippleDrawablegetOpacity in class LayerDrawableprotected boolean onStateChange(int[] stateSet)
onStateChange in class LayerDrawableprotected void onBoundsChange(android.graphics.Rect bounds)
onBoundsChange in class LayerDrawablepublic boolean setVisible(boolean visible,
boolean restart)
setVisible in class LayerDrawablepublic boolean isStateful()
isStateful in interface RippleDrawableisStateful in class LayerDrawablepublic void setColor(android.content.res.ColorStateList color)
color - Ripple color as a color state list.public void setRadius(int radius)
setRadius in interface RippleDrawableradius - ripple radius in pixels, or RADIUS_AUTO to compute the radius based on
the container sizepublic int getRadius()
getRadius in interface RippleDrawableRADIUS_AUTO if the radius is computed based on the container sizepublic void inflate(android.content.res.Resources r,
org.xmlpull.v1.XmlPullParser parser,
android.util.AttributeSet attrs,
android.content.res.Resources.Theme theme)
throws org.xmlpull.v1.XmlPullParserException,
java.io.IOException
LollipopDrawableinflate in class LayerDrawabler - Resources used to resolve attribute valuesparser - XML parser from which to inflate this Drawableattrs - Base set of attribute valuestheme - Theme to apply, may be nullorg.xmlpull.v1.XmlPullParserExceptionjava.io.IOExceptionpublic boolean setDrawableByLayerId(int id,
android.graphics.drawable.Drawable drawable)
LayerDrawableDrawable for the layer with the given id.setDrawableByLayerId in class LayerDrawableid - The layer ID to search for.drawable - The replacement Drawable.Drawable was replaced (could return false if the id was not
found).public void setPaddingMode(int mode)
LayerDrawable.PADDING_MODE_STACK.setPaddingMode in class LayerDrawablemode - padding mode, one of: LayerDrawable.PADDING_MODE_NEST to nest each layer
inside the padding of the previous layer LayerDrawable.PADDING_MODE_STACK to stack
each layer directly atop the previous layer LayerDrawable.getPaddingMode()public void applyTheme(android.content.res.Resources.Theme t)
LollipopDrawableapplyTheme in class LayerDrawablepublic boolean canApplyTheme()
canApplyTheme in class LayerDrawablepublic void setHotspot(float x,
float y)
LollipopDrawablesetHotspot in interface RippleDrawablesetHotspot in class LayerDrawablex - The X coordinate of the center of the hotspoty - The Y coordinate of the center of the hotspotpublic void setHotspotBounds(int left,
int top,
int right,
int bottom)
LollipopDrawablesetHotspotBounds in class LayerDrawablepublic void getHotspotBounds(android.graphics.Rect outRect)
getHotspotBounds in class LayerDrawablepublic void getOutline(@NonNull
android.graphics.Outline outline)
outline with the first available layer outline,
excluding the mask layer.getOutline in class LayerDrawableoutline - Outline in which to place the first available layer outlinepublic void draw(@NonNull
android.graphics.Canvas canvas)
draw in interface RippleDrawabledraw in class LayerDrawablepublic void invalidateSelf()
invalidateSelf in class android.graphics.drawable.Drawablepublic android.graphics.Rect getDirtyBounds()
getDirtyBounds in class android.graphics.drawable.Drawablepublic android.graphics.drawable.Drawable.ConstantState getConstantState()
getConstantState in class LayerDrawablepublic android.graphics.drawable.Drawable mutate()
mutate in class LayerDrawablepublic android.graphics.drawable.Drawable getBackground()
getBackground in interface RippleDrawablepublic RippleDrawable.Style getStyle()
getStyle in interface RippleDrawablepublic boolean isHotspotEnabled()
isHotspotEnabled in interface RippleDrawablepublic void setHotspotEnabled(boolean useHotspot)
setHotspotEnabled in interface RippleDrawablepublic android.content.res.ColorStateList getColor()
getColor in interface RippleDrawablepublic int getAlpha()
LollipopDrawablegetAlpha in interface AlphaDrawablegetAlpha in interface RippleDrawablegetAlpha in class LayerDrawable