Android 12 Developer Preview is here! Try it out, and give us your feedback!

MaterialShapeUtils

public class MaterialShapeUtils
extends Object

java.lang.Object
   ↳ com.google.android.material.shape.MaterialShapeUtils


Utility methods for MaterialShapeDrawable and related classes.

Summary

Public methods

static void setElevation(View view, float elevation)

If the background of the provided view is a MaterialShapeDrawable, sets the drawable's elevation via MaterialShapeDrawable.setElevation(float); otherwise does nothing.

static void setParentAbsoluteElevation(View view)

If the background of the provided view is a MaterialShapeDrawable, sets the drawable's parent absolute elevation (see setParentAbsoluteElevation(View, MaterialShapeDrawable)); otherwise does nothing.

static void setParentAbsoluteElevation(View view, MaterialShapeDrawable materialShapeDrawable)

Updates the materialShapeDrawable parent absolute elevation via MaterialShapeDrawable.setParentAbsoluteElevation(float) to be equal to the absolute elevation of the parent of the provided view.

Inherited methods

Public methods

setElevation

public static void setElevation (View view, 
                float elevation)

If the background of the provided view is a MaterialShapeDrawable, sets the drawable's elevation via MaterialShapeDrawable.setElevation(float); otherwise does nothing.

Parameters
view View

elevation float

setParentAbsoluteElevation

public static void setParentAbsoluteElevation (View view)

If the background of the provided view is a MaterialShapeDrawable, sets the drawable's parent absolute elevation (see setParentAbsoluteElevation(View, MaterialShapeDrawable)); otherwise does nothing.

Parameters
view View

setParentAbsoluteElevation

public static void setParentAbsoluteElevation (View view, 
                MaterialShapeDrawable materialShapeDrawable)

Updates the materialShapeDrawable parent absolute elevation via MaterialShapeDrawable.setParentAbsoluteElevation(float) to be equal to the absolute elevation of the parent of the provided view.

Parameters
view View

materialShapeDrawable MaterialShapeDrawable