ColorFilterDimmer

public final class ColorFilterDimmer


Helper class for applying a dim level to a View. The ColorFilterDimmer uses a ColorFilter in a Paint object to dim the view according to the currently active level.

Summary

Public methods

void

Apply current the ColorFilter to a View.

static ColorFilterDimmer
create(ColorFilterCache dimmer, float activeLevel, float dimmedLevel)

Creates a ColorFilterDimmer for the given color and levels..

static ColorFilterDimmer

Creates a default ColorFilterDimmer.

ColorFilter

Gets the ColorFilter set to the current dim level.

Paint

Gets the Paint object set to the current dim level.

void
setActiveLevel(float level)

Sets the active level of the dimmer.

Public methods

applyFilterToView

Added in 1.1.0
public void applyFilterToView(View view)

Apply current the ColorFilter to a View. This method will set the hardware layer of the view when applying a filter, and remove it when not applying a filter.

Parameters
View view

The View to apply the ColorFilter to.

create

Added in 1.1.0
public static ColorFilterDimmer create(ColorFilterCache dimmer, float activeLevel, float dimmedLevel)

Creates a ColorFilterDimmer for the given color and levels..

Parameters
ColorFilterCache dimmer

The ColorFilterCache for dim color.

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 ColorFilterDimmer createDefault(Context context)

Creates a default ColorFilterDimmer. Uses the default color and level for the dimmer.

Parameters
Context context

A Context used to retrieve Resources.

Returns
ColorFilterDimmer

A ColorFilterDimmer with the default dim color and levels.

getColorFilter

Added in 1.1.0
public ColorFilter getColorFilter()

Gets the ColorFilter set to the current dim level.

Returns
ColorFilter

The current ColorFilter.

getPaint

Added in 1.1.0
public Paint getPaint()

Gets the Paint object set to the current dim level.

Returns
Paint

The current Paint object.

setActiveLevel

Added in 1.1.0
public void setActiveLevel(float level)

Sets the active level of the dimmer. Updates the ColorFilter based on the level.

Parameters
float level

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