Class Overview
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
|
createDefault(Context context)
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
|
getAlpha()
Returns the alpha value for the dimmer.
|
float
|
getAlphaFloat()
Returns the float value between 0 and 1 corresponding to alpha between
0 and 255.
|
Paint
|
getPaint()
Returns the Paint object set to the current alpha value.
|
boolean
|
needsDraw()
Returns whether the dimmer needs to draw.
|
void
|
setActiveLevel(float level)
Sets the active level of the dimmer.
|
[Expand]
Inherited Methods |
From class
java.lang.Object
Object
|
clone()
Creates and returns a copy of this Object .
|
boolean
|
equals(Object o)
Compares this instance with the specified object and indicates if they
are equal.
|
void
|
finalize()
Invoked when the garbage collector has detected that this instance is no longer reachable.
|
final
Class<?>
|
getClass()
Returns the unique instance of Class that represents this
object's class.
|
int
|
hashCode()
Returns an integer hash code for this object.
|
final
void
|
notify()
Causes a thread which is waiting on this object's monitor (by means of
calling one of the wait() methods) to be woken up.
|
final
void
|
notifyAll()
Causes all threads which are waiting on this object's monitor (by means
of calling one of the wait() methods) to be woken up.
|
String
|
toString()
Returns a string containing a concise, human-readable description of this
object.
|
final
void
|
wait()
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object.
|
final
void
|
wait(long millis, int nanos)
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the
specified timeout expires.
|
final
void
|
wait(long millis)
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the
specified timeout expires.
|
|
Public Methods
public
int
applyToColor
(int color)
Change the RGB of the color according to current dim level. Maintains the
alpha value of the color.
Parameters
color
| The color to apply the dim level to. |
Returns
- A color with the RGB values adjusted by the alpha of the current
dim level.
public
static
ColorOverlayDimmer
createColorOverlayDimmer
(int dimColor, float activeLevel, float dimmedLevel)
Creates a ColorOverlayDimmer for the given color and levels.
Parameters
dimColor
| The color for fully dimmed. Only the RGB values are
used; the alpha channel is ignored. |
activeLevel
| The level of dimming when the View is in its active
state. Must be a float value between 0.0 and 1.0. |
dimmedLevel
| The level of dimming when the View is in its dimmed
state. Must be a float value between 0.0 and 1.0.
|
Creates a default ColorOverlayDimmer.
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
c
| Canvas of the parent View. |
v
| A child of the parent View. |
includePadding
| Set to true to draw overlay on padding area of the
View.
|
public
int
getAlpha
()
Returns the alpha value for the dimmer.
public
float
getAlphaFloat
()
Returns the float value between 0 and 1 corresponding to alpha between
0 and 255.
public
Paint
getPaint
()
Returns the Paint object set to the current alpha value.
public
boolean
needsDraw
()
Returns whether the dimmer needs to draw.
public
void
setActiveLevel
(float level)
Sets the active level of the dimmer. Updates the alpha value based on the
level.
Parameters
level
| A float between 0 (fully dim) and 1 (fully active).
|