RippleDrawableCompat

public class RippleDrawableCompat
extends Drawable implements Shapeable, TintAwareDrawable

java.lang.Object
   ↳ android.graphics.drawable.Drawable
     ↳ com.google.android.material.ripple.RippleDrawableCompat


A compat Drawable that is used to provide an overlay for pressed, focused, and hovered states (only when in enabled). This is intended to be used pre-Lollipop.

This Drawable is a MaterialShapeDrawable so that it can be shaped to match a MaterialShapeDrawable background.

Unlike the framework RippleDrawable, this will not apply different alphas for pressed, focused, and hovered states and it does not provide a ripple animation for the pressed state.

Summary

Public constructors

RippleDrawableCompat(ShapeAppearanceModel shapeAppearanceModel)

Creates a RippleDrawableCompat with the given shape that will only draw when enabled and at least one of: pressed, focused, or hovered.

Public methods

void draw(Canvas canvas)
Drawable.ConstantState getConstantState()
int getOpacity()
ShapeAppearanceModel getShapeAppearanceModel()

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

boolean isStateful()
RippleDrawableCompat mutate()
void setAlpha(int alpha)
void setColorFilter(ColorFilter colorFilter)
void setShapeAppearanceModel(ShapeAppearanceModel shapeAppearanceModel)

Sets the ShapeAppearanceModel that defines the shape.

void setTint(int tintColor)
void setTintList(ColorStateList tintList)
void setTintMode(PorterDuff.Mode tintMode)

Protected methods

void onBoundsChange(Rect bounds)
boolean onStateChange(int[] stateSet)

Inherited methods

void applyTheme(Resources.Theme arg0)
boolean canApplyTheme()
void clearColorFilter()
final Rect copyBounds()
final void copyBounds(Rect arg0)
static Drawable createFromPath(String arg0)
static Drawable createFromResourceStream(Resources arg0, TypedValue arg1, InputStream arg2, String arg3, BitmapFactory.Options arg4)
static Drawable createFromResourceStream(Resources arg0, TypedValue arg1, InputStream arg2, String arg3)
static Drawable createFromStream(InputStream arg0, String arg1)
static Drawable createFromXml(Resources arg0, XmlPullParser arg1)
static Drawable createFromXml(Resources arg0, XmlPullParser arg1, Resources.Theme arg2)
static Drawable createFromXmlInner(Resources arg0, XmlPullParser arg1, AttributeSet arg2, Resources.Theme arg3)
static Drawable createFromXmlInner(Resources arg0, XmlPullParser arg1, AttributeSet arg2)
abstract void draw(Canvas arg0)
int getAlpha()
final Rect getBounds()
Drawable.Callback getCallback()
int getChangingConfigurations()
ColorFilter getColorFilter()
Drawable.ConstantState getConstantState()
Drawable getCurrent()
Rect getDirtyBounds()
void getHotspotBounds(Rect arg0)
int getIntrinsicHeight()
int getIntrinsicWidth()
int getLayoutDirection()
final int getLevel()
int getMinimumHeight()
int getMinimumWidth()
abstract int getOpacity()
Insets getOpticalInsets()
void getOutline(Outline arg0)
boolean getPadding(Rect arg0)
int[] getState()
Region getTransparentRegion()
boolean hasFocusStateSpecified()
void inflate(Resources arg0, XmlPullParser arg1, AttributeSet arg2, Resources.Theme arg3)
void inflate(Resources arg0, XmlPullParser arg1, AttributeSet arg2)
void invalidateSelf()
boolean isAutoMirrored()
boolean isFilterBitmap()
boolean isProjected()
boolean isStateful()
final boolean isVisible()
void jumpToCurrentState()
Drawable mutate()
void onBoundsChange(Rect arg0)
boolean onLayoutDirectionChanged(int arg0)
boolean onLevelChange(int arg0)
boolean onStateChange(int[] arg0)
static int resolveOpacity(int arg0, int arg1)
void scheduleSelf(Runnable arg0, long arg1)
abstract void setAlpha(int arg0)
void setAutoMirrored(boolean arg0)
void setBounds(int arg0, int arg1, int arg2, int arg3)
void setBounds(Rect arg0)
final void setCallback(Drawable.Callback arg0)
void setChangingConfigurations(int arg0)
void setColorFilter(int arg0, PorterDuff.Mode arg1)
abstract void setColorFilter(ColorFilter arg0)
void setDither(boolean arg0)
void setFilterBitmap(boolean arg0)
void setHotspot(float arg0, float arg1)
void setHotspotBounds(int arg0, int arg1, int arg2, int arg3)
final boolean setLayoutDirection(int arg0)
final boolean setLevel(int arg0)
boolean setState(int[] arg0)
void setTint(int arg0)
void setTintBlendMode(BlendMode arg0)
void setTintList(ColorStateList arg0)
void setTintMode(PorterDuff.Mode arg0)
boolean setVisible(boolean arg0, boolean arg1)
void unscheduleSelf(Runnable arg0)
Object clone()
boolean equals(Object arg0)
void finalize()
final Class<?> getClass()
int hashCode()
final void notify()
final void notifyAll()
String toString()
final void wait(long arg0, int arg1)
final void wait(long arg0)
final void wait()
abstract ShapeAppearanceModel getShapeAppearanceModel()

Returns the ShapeAppearanceModel used for the shape definition.

abstract void setShapeAppearanceModel(ShapeAppearanceModel shapeAppearanceModel)

Sets the ShapeAppearanceModel that defines the shape.

abstract void setTint(int arg0)
abstract void setTintList(ColorStateList arg0)
abstract void setTintMode(PorterDuff.Mode arg0)

Public constructors

RippleDrawableCompat

public RippleDrawableCompat (ShapeAppearanceModel shapeAppearanceModel)

Creates a RippleDrawableCompat with the given shape that will only draw when enabled and at least one of: pressed, focused, or hovered.

Parameters
shapeAppearanceModel ShapeAppearanceModel: The shape for the ripple.

Public methods

draw

public void draw (Canvas canvas)

Parameters
canvas Canvas

getConstantState

public Drawable.ConstantState getConstantState ()

Returns
Drawable.ConstantState

getOpacity

public int getOpacity ()

Returns
int

getShapeAppearanceModel

public ShapeAppearanceModel getShapeAppearanceModel ()

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

Returns
ShapeAppearanceModel the current model.

isStateful

public boolean isStateful ()

Returns
boolean

mutate

public RippleDrawableCompat mutate ()

setAlpha

public void setAlpha (int alpha)

Parameters
alpha int

setColorFilter

public void setColorFilter (ColorFilter colorFilter)

Parameters
colorFilter ColorFilter

setShapeAppearanceModel

public void setShapeAppearanceModel (ShapeAppearanceModel shapeAppearanceModel)

Sets the ShapeAppearanceModel that defines the shape.

Parameters
shapeAppearanceModel ShapeAppearanceModel

setTint

public void setTint (int tintColor)

Parameters
tintColor int

setTintList

public void setTintList (ColorStateList tintList)

Parameters
tintList ColorStateList

setTintMode

public void setTintMode (PorterDuff.Mode tintMode)

Parameters
tintMode PorterDuff.Mode

Protected methods

onBoundsChange

protected void onBoundsChange (Rect bounds)

Parameters
bounds Rect

onStateChange

protected boolean onStateChange (int[] stateSet)

Parameters
stateSet int

Returns
boolean

With Android you can distribute apps to users in any way you want, using any store or distribution approach.

Updated Apr 16, 2020

Discover the latest app development tools, platform updates, training, and documentation for developers across every Android device.

Updated Feb 16, 2024

Develop your UI on Android.

Updated Feb 22, 2024