The Android Developer Challenge is back! Submit your idea before December 2.

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(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>

ShadowOverlayContainer(context: Context!)

Create ShadowOverlayContainer and auto select shadow type.

<init>

ShadowOverlayContainer(context: Context!, attrs: AttributeSet!)

Create ShadowOverlayContainer and auto select shadow type.

<init>

ShadowOverlayContainer(context: Context!, attrs: AttributeSet!, defStyle: Int)

Create ShadowOverlayContainer and auto select shadow type.

Public methods

draw

open fun draw(canvas: Canvas!): Unit

getShadowType

open fun getShadowType(): Int

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

getWrappedView

open fun getWrappedView(): View!

Returns the wrapper view.

hasOverlappingRendering

open fun hasOverlappingRendering(): Boolean

initialize

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

Deprecated: use ShadowOverlayHelper#createShadowOverlayContainer(Context) instead.

Initialize shadows, color overlay.

initialize

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

Deprecated: use ShadowOverlayHelper#createShadowOverlayContainer(Context) instead.

Initialize shadows, color overlay, and rounded corners. All are optional. Shadow type are auto-selected based on useStaticShadow() and useDynamicShadow() call.

prepareParentForShadow

open static fun prepareParentForShadow(parent: ViewGroup!): Unit

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

setOverlayColor

open fun setOverlayColor(overlayColor: Int): Unit

Set color (with alpha) of the overlay.

setShadowFocusLevel

open fun setShadowFocusLevel(level: Float): Unit

Set shadow focus level (0 to 1). 0 for unfocused, 1f for fully focused.

supportsDynamicShadow

open static fun supportsDynamicShadow(): Boolean

Returns true if the platform sdk supports dynamic shadows.

supportsShadow

open static fun supportsShadow(): Boolean

Return true if the platform sdk supports shadow.

useDynamicShadow

open fun useDynamicShadow(): Unit

Sets the shadow type to SHADOW_DYNAMIC if supported.

useDynamicShadow

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

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

useStaticShadow

open fun useStaticShadow(): Unit

Sets the shadow type to SHADOW_STATIC if supported.

wrap

open fun wrap(view: View!): Unit

Inserts view into the wrapper.

Protected methods

onLayout

protected open fun onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int): Unit