net.simonvt.menudrawer
Class ColorDrawable

java.lang.Object
  extended by android.graphics.drawable.Drawable
      extended by net.simonvt.menudrawer.ColorDrawable

public class ColorDrawable
extends android.graphics.drawable.Drawable

A specialized Drawable that fills the Canvas with a specified color. Note that a ColorDrawable ignores the ColorFilter.

It can be defined in an XML file with the <color> element.


Nested Class Summary
 
Nested classes/interfaces inherited from class android.graphics.drawable.Drawable
android.graphics.drawable.Drawable.Callback, android.graphics.drawable.Drawable.ConstantState
 
Constructor Summary
ColorDrawable()
          Creates a new black ColorDrawable.
ColorDrawable(int color)
          Creates a new ColorDrawable with the specified color.
 
Method Summary
 void draw(android.graphics.Canvas canvas)
           
 int getAlpha()
          Returns the alpha value of this drawable's color.
 int getChangingConfigurations()
           
 int getColor()
          Gets the drawable's color value.
 android.graphics.drawable.Drawable.ConstantState getConstantState()
           
 int getOpacity()
           
 void setAlpha(int alpha)
          Sets the color's alpha value.
 void setColor(int color)
          Sets the drawable's color value.
 void setColorFilter(android.graphics.ColorFilter colorFilter)
          Setting a color filter on a ColorDrawable has no effect.
 
Methods inherited from class android.graphics.drawable.Drawable
clearColorFilter, copyBounds, copyBounds, createFromPath, createFromResourceStream, createFromResourceStream, createFromStream, createFromXml, createFromXmlInner, getBounds, getCallback, getCurrent, getIntrinsicHeight, getIntrinsicWidth, getLevel, getMinimumHeight, getMinimumWidth, getPadding, getState, getTransparentRegion, inflate, invalidateSelf, isStateful, isVisible, jumpToCurrentState, mutate, onBoundsChange, onLevelChange, onStateChange, resolveOpacity, scheduleSelf, setBounds, setBounds, setCallback, setChangingConfigurations, setColorFilter, setDither, setFilterBitmap, setLevel, setState, setVisible, unscheduleSelf
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ColorDrawable

public ColorDrawable()
Creates a new black ColorDrawable.


ColorDrawable

public ColorDrawable(int color)
Creates a new ColorDrawable with the specified color.

Parameters:
color - The color to draw.
Method Detail

getChangingConfigurations

public int getChangingConfigurations()
Overrides:
getChangingConfigurations in class android.graphics.drawable.Drawable

draw

public void draw(android.graphics.Canvas canvas)
Specified by:
draw in class android.graphics.drawable.Drawable

getColor

public int getColor()
Gets the drawable's color value.

Returns:
int The color to draw.

setColor

public void setColor(int color)
Sets the drawable's color value. This action will clobber the results of prior calls to setAlpha(int) on this object, which side-affected the underlying color.

Parameters:
color - The color to draw.

getAlpha

public int getAlpha()
Returns the alpha value of this drawable's color.

Returns:
A value between 0 and 255.

setAlpha

public void setAlpha(int alpha)
Sets the color's alpha value.

Specified by:
setAlpha in class android.graphics.drawable.Drawable
Parameters:
alpha - The alpha value to set, between 0 and 255.

setColorFilter

public void setColorFilter(android.graphics.ColorFilter colorFilter)
Setting a color filter on a ColorDrawable has no effect.

Specified by:
setColorFilter in class android.graphics.drawable.Drawable
Parameters:
colorFilter - Ignore.

getOpacity

public int getOpacity()
Specified by:
getOpacity in class android.graphics.drawable.Drawable

getConstantState

public android.graphics.drawable.Drawable.ConstantState getConstantState()
Overrides:
getConstantState in class android.graphics.drawable.Drawable


Copyright © 2012-2013. All Rights Reserved.