MaterialShapeDrawable

Base drawable class for Material Shapes that handles shadows, elevation, scale and color for a generated path.

Inheritors

Constructors

Link copied to clipboard
constructor()
constructor(@NonNull context: Context, @Nullable attrs: AttributeSet, @AttrRes defStyleAttr: Int, @StyleRes defStyleRes: Int)
constructor(@NonNull shapePathModel: ShapePathModel)
constructor(@NonNull shapeAppearanceModel: ShapeAppearanceModel)

Types

Link copied to clipboard
Determines when compatibility shadow is drawn vs.

Properties

Link copied to clipboard
Link copied to clipboard
Always draw fake shadows, never draw native elevation shadows.
Link copied to clipboard
Try to draw native elevation shadows if possible, otherwise use fake shadows.
Link copied to clipboard
Never draw fake shadows.
Link copied to clipboard

Functions

Link copied to clipboard
Returns a MaterialShapeDrawable with the elevation overlay functionality initialized, a fill color of colorSurface, and an elevation of 0.
Returns a MaterialShapeDrawable with the elevation overlay functionality initialized, a fill color of colorSurface, and an elevation of elevation.
Returns a MaterialShapeDrawable with the elevation overlay functionality initialized, a fill color of backgroundTint, and an elevation of elevation.
Link copied to clipboard
open fun draw(@NonNull canvas: Canvas)
Link copied to clipboard
open fun getAlpha(): Int
Link copied to clipboard
Returns the actual size of the bottom left corner for the current bounds.
Link copied to clipboard
Returns the actual size of the bottom right corner for the current bounds.
Link copied to clipboard
Link copied to clipboard
open fun getElevation(): Float
Returns the elevation used to render both fake shadows when requiresCompatShadow is true and elevation overlays.
Link copied to clipboard
Get the color used for the fill.
Link copied to clipboard
Get the interpolation of the path, between 0 and 1.
Link copied to clipboard
open fun getOpacity(): Int
Link copied to clipboard
open fun getOutline(@NonNull outline: Outline)
Link copied to clipboard
open fun getPadding(@NonNull padding: Rect): Boolean
Link copied to clipboard
Get the current style used by the shape's paint.
Link copied to clipboard
Returns the parent absolute elevation.
Link copied to clipboard
open fun getPathForSize(width: Int, height: Int, @NonNull path: Path)
Link copied to clipboard
open fun getScale(): Float
Get the scale of the rendered path.
Link copied to clipboard
Link copied to clipboard
Returns the rotation offset applied to the fake shadow which is drawn when requiresCompatShadow is true.
Link copied to clipboard
Get the shadow elevation rendered by the path.
Link copied to clipboard
open fun getShadowOffsetX(): Int
Returns the X offset of the shadow from the bounds of the shape.
Link copied to clipboard
open fun getShadowOffsetY(): Int
Returns the Y offset of the shadow from the bounds of the shape.
Link copied to clipboard
open fun getShadowRadius(): Int
Get the shadow radius rendered by the path in pixels.
Link copied to clipboard
Returns the shadow vertical offset rendered for shadows when requiresCompatShadow is true.
Link copied to clipboard
Get the ShapeAppearanceModel containing the path that will be rendered in this drawable.
Link copied to clipboard
Get the ShapePathModel containing the path that will be rendered in this drawable.
Link copied to clipboard
Get the color used for the stroke.
Link copied to clipboard
Get the stroke's current ColorStateList.
Link copied to clipboard
open fun getStrokeWidth(): Float
Get the stroke width used by the shape's paint.
Link copied to clipboard
Get the tint list used by the shape's paint.
Link copied to clipboard
Returns the actual size of the top left corner for the current bounds.
Link copied to clipboard
Returns the actual size of the top right corner for the current bounds.
Link copied to clipboard
Returns the translationZ used to render both fake shadows when requiresCompatShadow is true and elevation overlays.
Link copied to clipboard
open fun getZ(): Float
Returns the visual z position of this drawable, in pixels.
Link copied to clipboard
Initializes the elevation overlay functionality for this drawable.
Link copied to clipboard
open fun invalidateSelf()
Link copied to clipboard
Returns whether the elevation overlay functionality is initialized and enabled in this drawable's theme context.
Link copied to clipboard
Returns whether the elevation overlay functionality has been initialized for this drawable.
Link copied to clipboard
Determines whether a point is contained within the transparent region of the Drawable.
Link copied to clipboard
Checks Corner and Edge treatments to see if we can use drawRoundRect "} to draw this model.
Link copied to clipboard
Get shadow rendering status for shadows when requiresCompatShadow is true.
Link copied to clipboard
open fun isStateful(): Boolean
Link copied to clipboard
open fun mutate(): Drawable
Link copied to clipboard
Returns true if fake shadows should be drawn.
Link copied to clipboard
open fun setAlpha(@IntRange(from = 0, to = 255) alpha: Int)
Link copied to clipboard
open fun setColorFilter(@Nullable colorFilter: ColorFilter)
Link copied to clipboard
open fun setCornerSize(@NonNull cornerSize: CornerSize)
open fun setCornerSize(cornerSize: Float)
Updates the corners for the given CornerSize.
Link copied to clipboard
open fun setElevation(elevation: Float)
Sets the elevation used to render both fake shadows when requiresCompatShadow is true and elevation overlays.
Link copied to clipboard
open fun setFillColor(@Nullable fillColor: ColorStateList)
Set the color used for the fill.
Link copied to clipboard
open fun setInterpolation(interpolation: Float)
Set the interpolation of the path, between 0 and 1.
Link copied to clipboard
open fun setPadding(left: Int, top: Int, right: Int, bottom: Int)
Configure the padding of the shape
Link copied to clipboard
open fun setPaintStyle(paintStyle: Paint.Style)
Set the style used by the shape's paint.
Link copied to clipboard
open fun setParentAbsoluteElevation(parentAbsoluteElevation: Float)
Sets the parent absolute elevation, which is used to render elevation overlays.
Link copied to clipboard
open fun setScale(scale: Float)
Set the scale of the rendered path.
Link copied to clipboard
Link copied to clipboard
open fun setShadowColor(shadowColor: Int)
Set the color of fake shadow rendered behind the shape.
Link copied to clipboard
Set the shadow compatibility mode.
Link copied to clipboard
open fun setShadowCompatRotation(shadowRotation: Int)
Set the rotation offset applied to the fake shadow which is drawn when requiresCompatShadow is true.
Link copied to clipboard
open fun setShadowElevation(shadowElevation: Int)
Set the shadow elevation rendered by the path.
Link copied to clipboard
open fun setShadowEnabled(shadowEnabled: Boolean)
Set shadow rendering to be enabled or disabled when requiresCompatShadow is true.
Link copied to clipboard
open fun setShadowRadius(shadowRadius: Int)
Set the shadow radius rendered by the path.
Link copied to clipboard
open fun setShadowVerticalOffset(shadowOffset: Int)
Sets the shadow offset rendered by the fake shadow when requiresCompatShadow is true.
Link copied to clipboard
open fun setShapeAppearanceModel(@NonNull shapeAppearanceModel: ShapeAppearanceModel)
Set the ShapeAppearanceModel containing the path that will be rendered in this drawable.
Link copied to clipboard
open fun setShapedViewModel(@NonNull shapedViewModel: ShapePathModel)
Set the ShapePathModel containing the path that will be rendered in this drawable.
Link copied to clipboard
open fun setStroke(strokeWidth: Float, @Nullable strokeColor: ColorStateList)
Set the shape's stroke width and stroke color using a ColorStateList.
open fun setStroke(strokeWidth: Float, @ColorInt strokeColor: Int)
Set the shape's stroke width and stroke color.
Link copied to clipboard
open fun setStrokeColor(@Nullable strokeColor: ColorStateList)
Set the color used for the stroke.
Link copied to clipboard
open fun setStrokeTint(tintList: ColorStateList)
Set the shape's stroke ColorStateList
open fun setStrokeTint(@ColorInt tintColor: Int)
Set the shape's stroke color.
Link copied to clipboard
open fun setStrokeWidth(strokeWidth: Float)
Set the stroke width used by the shape's paint.
Link copied to clipboard
open fun setTint(@ColorInt tintColor: Int)
Link copied to clipboard
open fun setTintList(@Nullable tintList: ColorStateList)
Link copied to clipboard
open fun setTintMode(@Nullable tintMode: PorterDuff.Mode)
Link copied to clipboard
open fun setTranslationZ(translationZ: Float)
Sets the translationZ used to render both fake shadows when requiresCompatShadow is true and elevation overlays.
Link copied to clipboard
open fun setUseTintColorForShadow(useTintColorForShadow: Boolean)
Set whether fake shadow color should match next set tint color.
Link copied to clipboard
open fun setZ(z: Float)
Sets the visual z position of this view, in pixels.