The second Android 11 Developer Preview is now available, test it out and share your feedback.

ColorPainter

data class ColorPainter : Painter
kotlin.Any
   ↳ androidx.ui.graphics.painter.Painter
   ↳ androidx.ui.graphics.painter.ColorPainter

Painter implementation used to fill the provided bounds with the specified color

Summary

Public constructors

<init>(color: Color)

Painter implementation used to fill the provided bounds with the specified color

Protected methods

Boolean
applyAlpha(alpha: Float)

Apply the provided alpha value returning true if it was applied successfully, or false if it could not be applied

Boolean

Apply the provided color filter returning true if it was applied successfully, or false if it could not be applied

Unit
onDraw(canvas: Canvas, bounds: PxSize)

Implementation of drawing logic for instances of Painter.

Inherited functions

Inherited extension functions

From androidx.ui.core
DrawModifier
Painter.asModifier(sizeToIntrinsics: Boolean = true, alignment: Alignment = Alignment.Center, scaleFit: ScaleFit = ScaleFit.Fit, alpha: Float = DefaultAlpha, colorFilter: ColorFilter? = null, rtl: Boolean = false)

Create a DrawModifier from this Painter.

Properties

Color

PxSize

Drawing a color does not have an intrinsic size, return UnspecifiedSize here

Public constructors

<init>

ColorPainter(color: Color)

Painter implementation used to fill the provided bounds with the specified color

Protected methods

applyAlpha

protected fun applyAlpha(alpha: Float): Boolean

Apply the provided alpha value returning true if it was applied successfully, or false if it could not be applied

applyColorFilter

protected fun applyColorFilter(colorFilter: ColorFilter?): Boolean

Apply the provided color filter returning true if it was applied successfully, or false if it could not be applied

onDraw

protected fun onDraw(
    canvas: Canvas,
    bounds: PxSize
): Unit

Implementation of drawing logic for instances of Painter. This is invoked internally within draw after the positioning and configuring the Painter

Properties

color

val color: Color

intrinsicSize

val intrinsicSize: PxSize

Drawing a color does not have an intrinsic size, return UnspecifiedSize here