Register now for Android Dev Summit 2019!

ColorOverlayDimmer

class ColorOverlayDimmer
kotlin.Any
   ↳ androidx.leanback.graphics.ColorOverlayDimmer

Helper class for assigning a dim color to Paint. It holds the alpha value for the current active level.

Summary

Public methods

Int
applyToColor(color: Int)

Change the RGB of the color according to current dim level.

static ColorOverlayDimmer!
createColorOverlayDimmer(dimColor: Int, activeLevel: Float, dimmedLevel: Float)

Creates a ColorOverlayDimmer for the given color and levels.

static ColorOverlayDimmer!

Creates a default ColorOverlayDimmer.

Unit
drawColorOverlay(c: Canvas!, v: View!, includePadding: Boolean)

Draw a dim color overlay on top of a child View inside the canvas of the parent View.

Int

Returns the alpha value for the dimmer.

Float

Returns the float value between 0 and 1 corresponding to alpha between 0 and 255.

Paint!

Returns the Paint object set to the current alpha value.

Boolean

Returns whether the dimmer needs to draw.

Unit

Sets the active level of the dimmer.

Public methods

applyToColor

fun applyToColor(color: Int): Int

Change the RGB of the color according to current dim level. Maintains the alpha value of the color.

Parameters
color Int: The color to apply the dim level to.
Return
Int: A color with the RGB values adjusted by the alpha of the current dim level.

createColorOverlayDimmer

static fun createColorOverlayDimmer(dimColor: Int, activeLevel: Float, dimmedLevel: Float): ColorOverlayDimmer!

Creates a ColorOverlayDimmer for the given color and levels.

Parameters
dimColor Int: The color for fully dimmed. Only the RGB values are used; the alpha channel is ignored.
activeLevel Int: The level of dimming when the View is in its active state. Must be a float value between 0.0 and 1.0.
dimmedLevel Int: The level of dimming when the View is in its dimmed state. Must be a float value between 0.0 and 1.0.

createDefault

static fun createDefault(context: Context!): ColorOverlayDimmer!

Creates a default ColorOverlayDimmer.

drawColorOverlay

fun drawColorOverlay(c: Canvas!, v: View!, includePadding: Boolean): Unit

Draw a dim color overlay on top of a child View inside the canvas of the parent View.

Parameters
c Canvas!: Canvas of the parent View.
v Canvas!: A child of the parent View.
includePadding Canvas!: Set to true to draw overlay on padding area of the View.

getAlpha

fun getAlpha(): Int

Returns the alpha value for the dimmer.

getAlphaFloat

fun getAlphaFloat(): Float

Returns the float value between 0 and 1 corresponding to alpha between 0 and 255.

getPaint

fun getPaint(): Paint!

Returns the Paint object set to the current alpha value.

needsDraw

fun needsDraw(): Boolean

Returns whether the dimmer needs to draw.

setActiveLevel

fun setActiveLevel(level: Float): Unit

Sets the active level of the dimmer. Updates the alpha value based on the level.

Parameters
level Float: A float between 0 (fully dim) and 1 (fully active).