lightbulb_outline Please take our October 2018 developer survey. Start survey

ShadowDrawableWrapper

public class ShadowDrawableWrapper
extends DrawableWrapper

java.lang.Object
   ↳ android.graphics.drawable.Drawable
     ↳ android.support.v7.graphics.drawable.DrawableWrapper
       ↳ com.google.android.material.shadow.ShadowDrawableWrapper


A Drawable which wraps another drawable and draws a shadow around it.

Summary

Public constructors

ShadowDrawableWrapper(Context context, Drawable content, float radius, float shadowSize, float maxShadowSize)

Public methods

static float calculateHorizontalPadding(float maxShadowSize, float cornerRadius, boolean addPaddingForCorners)
static float calculateVerticalPadding(float maxShadowSize, float cornerRadius, boolean addPaddingForCorners)
void draw(Canvas canvas)
float getCornerRadius()
float getMaxShadowSize()
float getMinHeight()
float getMinWidth()
int getOpacity()
boolean getPadding(Rect padding)
float getShadowSize()
void setAddPaddingForCorners(boolean addPaddingForCorners)
void setAlpha(int alpha)
void setCornerRadius(float radius)
void setMaxShadowSize(float size)
final void setRotation(float rotation)
void setShadowSize(float size)
void setShadowSize(float shadowSize, float maxShadowSize)

Protected methods

void onBoundsChange(Rect bounds)

Inherited methods

From class android.support.v7.graphics.drawable.DrawableWrapper
From class android.graphics.drawable.Drawable
From class java.lang.Object
From interface android.graphics.drawable.Drawable.Callback

Public constructors

ShadowDrawableWrapper

ShadowDrawableWrapper (Context context, 
                Drawable content, 
                float radius, 
                float shadowSize, 
                float maxShadowSize)

Parameters
context Context

content Drawable

radius float

shadowSize float

maxShadowSize float

Public methods

calculateHorizontalPadding

float calculateHorizontalPadding (float maxShadowSize, 
                float cornerRadius, 
                boolean addPaddingForCorners)

Parameters
maxShadowSize float

cornerRadius float

addPaddingForCorners boolean

Returns
float

calculateVerticalPadding

float calculateVerticalPadding (float maxShadowSize, 
                float cornerRadius, 
                boolean addPaddingForCorners)

Parameters
maxShadowSize float

cornerRadius float

addPaddingForCorners boolean

Returns
float

draw

void draw (Canvas canvas)

Parameters
canvas Canvas

getCornerRadius

float getCornerRadius ()

Returns
float

getMaxShadowSize

float getMaxShadowSize ()

Returns
float

getMinHeight

float getMinHeight ()

Returns
float

getMinWidth

float getMinWidth ()

Returns
float

getOpacity

int getOpacity ()

Returns
int

getPadding

boolean getPadding (Rect padding)

Parameters
padding Rect

Returns
boolean

getShadowSize

float getShadowSize ()

Returns
float

setAddPaddingForCorners

void setAddPaddingForCorners (boolean addPaddingForCorners)

Parameters
addPaddingForCorners boolean

setAlpha

void setAlpha (int alpha)

Parameters
alpha int

setCornerRadius

void setCornerRadius (float radius)

Parameters
radius float

setMaxShadowSize

void setMaxShadowSize (float size)

Parameters
size float

setRotation

void setRotation (float rotation)

Parameters
rotation float

setShadowSize

void setShadowSize (float size)

Parameters
size float

setShadowSize

void setShadowSize (float shadowSize, 
                float maxShadowSize)

Parameters
shadowSize float

maxShadowSize float

Protected methods

onBoundsChange

void onBoundsChange (Rect bounds)

Parameters
bounds Rect