ColorOverlayDimmer

public final class 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(int color)

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

static ColorOverlayDimmer
createColorOverlayDimmer(
    int dimColor,
    float activeLevel,
    float dimmedLevel
)

Creates a ColorOverlayDimmer for the given color and levels.

static ColorOverlayDimmer

Creates a default ColorOverlayDimmer.

void
drawColorOverlay(Canvas c, View v, boolean includePadding)

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.

void
setActiveLevel(float level)

Sets the active level of the dimmer.

Public methods

applyToColor

Added in 1.1.0
public int applyToColor(int color)

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

Parameters
int color

The color to apply the dim level to.

Returns
int

A color with the RGB values adjusted by the alpha of the current dim level.

createColorOverlayDimmer

Added in 1.1.0
public static ColorOverlayDimmer createColorOverlayDimmer(
    int dimColor,
    float activeLevel,
    float dimmedLevel
)

Creates a ColorOverlayDimmer for the given color and levels.

Parameters
int dimColor

The color for fully dimmed. Only the RGB values are used; the alpha channel is ignored.

float activeLevel

The level of dimming when the View is in its active state. Must be a float value between 0.0 and 1.0.

float dimmedLevel

The level of dimming when the View is in its dimmed state. Must be a float value between 0.0 and 1.0.

createDefault

Added in 1.1.0
public static ColorOverlayDimmer createDefault(Context context)

Creates a default ColorOverlayDimmer.

drawColorOverlay

Added in 1.1.0
public void drawColorOverlay(Canvas c, View v, boolean includePadding)

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

Parameters
Canvas c

Canvas of the parent View.

View v

A child of the parent View.

boolean includePadding

Set to true to draw overlay on padding area of the View.

getAlpha

Added in 1.1.0
public int getAlpha()

Returns the alpha value for the dimmer.

getAlphaFloat

Added in 1.1.0
public float getAlphaFloat()

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

getPaint

Added in 1.1.0
public Paint getPaint()

Returns the Paint object set to the current alpha value.

needsDraw

Added in 1.1.0
public boolean needsDraw()

Returns whether the dimmer needs to draw.

setActiveLevel

Added in 1.1.0
public void setActiveLevel(float level)

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

Parameters
float level

A float between 0 (fully dim) and 1 (fully active).