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 leaste one of: presssed, 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

From class android.graphics.drawable.Drawable
From class java.lang.Object
From interface com.google.android.material.shape.Shapeable
From interface androidx.core.graphics.drawable.TintAwareDrawable

Public constructors

RippleDrawableCompat

RippleDrawableCompat (ShapeAppearanceModel shapeAppearanceModel)

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

Parameters
shapeAppearanceModel ShapeAppearanceModel: The shape for the ripple.

Public methods

draw

void draw (Canvas canvas)

Parameters
canvas Canvas

getConstantState

Drawable.ConstantState getConstantState ()

Returns
Drawable.ConstantState

getOpacity

int getOpacity ()

Returns
int

getShapeAppearanceModel

ShapeAppearanceModel getShapeAppearanceModel ()

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

Returns
ShapeAppearanceModel the current model.

isStateful

boolean isStateful ()

Returns
boolean

mutate

RippleDrawableCompat mutate ()

Returns
RippleDrawableCompat

setAlpha

void setAlpha (int alpha)

Parameters
alpha int

setColorFilter

void setColorFilter (ColorFilter colorFilter)

Parameters
colorFilter ColorFilter

setShapeAppearanceModel

void setShapeAppearanceModel (ShapeAppearanceModel shapeAppearanceModel)

Sets the ShapeAppearanceModel that defines the shape.

Parameters
shapeAppearanceModel ShapeAppearanceModel

setTint

void setTint (int tintColor)

Parameters
tintColor int

setTintList

void setTintList (ColorStateList tintList)

Parameters
tintList ColorStateList

setTintMode

void setTintMode (PorterDuff.Mode tintMode)

Parameters
tintMode PorterDuff.Mode

Protected methods

onBoundsChange

void onBoundsChange (Rect bounds)

Parameters
bounds Rect

onStateChange

boolean onStateChange (int[] stateSet)

Parameters
stateSet int

Returns
boolean