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

CacheDrawScope

class CacheDrawScope : Density
kotlin.Any
   ↳ androidx.compose.ui.draw.CacheDrawScope

Handle to a drawing environment that enables caching of content based on the resolved size. Consumers define parameters and refer to them in the captured draw callback provided in onDrawBehind or onDrawWithContent.

onDrawBehind will draw behind the layout's drawing contents however, onDrawWithContent will provide the ability to draw before or after the layout's contents

Summary

Public methods
DrawResult
onDrawBehind(block: DrawScope.() -> Unit)

Issue drawing commands to be executed before the layout content is drawn

DrawResult

Issue drawing commands before or after the layout's drawing contents

Inherited functions
Properties
Float

The logical density of the display.

Float

Current user preference for the scaling factor for fonts.

LayoutDirection

Provides the LayoutDirection.

Size

Provides the dimensions of the current drawing environment

Public methods

onDrawBehind

fun onDrawBehind(block: DrawScope.() -> Unit): DrawResult

Issue drawing commands to be executed before the layout content is drawn

onDrawWithContent

fun onDrawWithContent(block: ContentDrawScope.() -> Unit): DrawResult

Issue drawing commands before or after the layout's drawing contents

Properties

density

val density: Float

The logical density of the display. This is a scaling factor for the Dp unit.

fontScale

val fontScale: Float

Current user preference for the scaling factor for fonts.

layoutDirection

val layoutDirection: LayoutDirection

Provides the LayoutDirection.

size

val size: Size

Provides the dimensions of the current drawing environment