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

ShadowOverlayContainer

open class ShadowOverlayContainer : FrameLayout
kotlin.Any
   ↳ android.view.View
   ↳ android.view.ViewGroup
   ↳ android.widget.FrameLayout
   ↳ androidx.leanback.widget.ShadowOverlayContainer

Provides an SDK version-independent wrapper to support shadows, color overlays, and rounded corners. It's not always preferred to create a ShadowOverlayContainer, use ShadowOverlayHelper instead.

prepareParentForShadow(ViewGroup) must be called on parent of container before using shadow. Depending on sdk version, optical bounds might be applied to parent.

If shadows can appear outside the bounds of the parent view, setClipChildren(false) must be called on the grandparent view.

initialize(boolean, boolean, boolean) must be first called on the container. Then call wrap(View) to insert the wrapped view into the container.

Call setShadowFocusLevel(float) to control the strength of the shadow (focused shadows cast stronger shadows).

Call setOverlayColor(int) to control overlay color.

Summary

Constants
static Int

Shadows depend on the size, shape, and position of the view.

static Int

No shadow.

static Int

Shadows are fixed.

Public constructors
<init>(context: Context!)

Create ShadowOverlayContainer and auto select shadow type.

<init>(context: Context!, attrs: AttributeSet!)

Create ShadowOverlayContainer and auto select shadow type.

<init>(context: Context!, attrs: AttributeSet!, defStyle: Int)

Create ShadowOverlayContainer and auto select shadow type.

Public methods
open Unit
draw(canvas: Canvas!)

open Int

Returns the shadow type, one of SHADOW_NONE, SHADOW_STATIC, or SHADOW_DYNAMIC.

open View!

Returns the wrapper view.

open Boolean

open Unit
initialize(hasShadow: Boolean, hasColorDimOverlay: Boolean)

Initialize shadows, color overlay.

open Unit
initialize(hasShadow: Boolean, hasColorDimOverlay: Boolean, roundedCorners: Boolean)

Initialize shadows, color overlay, and rounded corners.

open static Unit

prepareParentForShadow(ViewGroup) must be called on parent of container before using shadow.

open Unit
setOverlayColor(@ColorInt overlayColor: Int)

Set color (with alpha) of the overlay.

open Unit

Set shadow focus level (0 to 1).

open static Boolean

Returns true if the platform sdk supports dynamic shadows.

open static Boolean

Return true if the platform sdk supports shadow.

open Unit

Sets the shadow type to SHADOW_DYNAMIC if supported.

open Unit
useDynamicShadow(unfocusedZ: Float, focusedZ: Float)

Sets the shadow type to SHADOW_DYNAMIC if supported and sets the elevation/Z values to the given parameters.

open Unit

Sets the shadow type to SHADOW_STATIC if supported.

open Unit
wrap(view: View!)

Inserts view into the wrapper.

Protected methods
open Unit
onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int)

Constants

SHADOW_DYNAMIC

static val SHADOW_DYNAMIC: Int

Shadows depend on the size, shape, and position of the view.

Value: ShadowOverlayHelper.SHADOW_DYNAMIC

SHADOW_NONE

static val SHADOW_NONE: Int

No shadow.

Value: ShadowOverlayHelper.SHADOW_NONE

SHADOW_STATIC

static val SHADOW_STATIC: Int

Shadows are fixed.

Value: ShadowOverlayHelper.SHADOW_STATIC

Public constructors

<init>