Build 1.0_r1(from source)

android.graphics.drawable
Class ColorDrawable

java.lang.Object
  extended by android.graphics.drawable.Drawable
      extended by android.graphics.drawable.ColorDrawable

public class ColorDrawable
extends Drawable

A ColorDrawable is a specialized drawable that fills the Canvas with a specified color, and with respect to the clip region. Note that a ColorDrawable ignores the ColorFilter. It also ignores the Bounds, meaning it will draw everywhere in the current clip, even if setBounds(...) was called with a smaller area.


Nested Class Summary
(package private) static class ColorDrawable.ColorState
           
 
Nested classes/interfaces inherited from class android.graphics.drawable.Drawable
Drawable.Callback, Drawable.ConstantState
 
Field Summary
 
Fields inherited from class android.graphics.drawable.Drawable
mCallback
 
Constructor Summary
ColorDrawable()
          Creates a new black ColorDrawable.
ColorDrawable(int color)
          Creates a new ColorDrawable with the specified color.
 
Method Summary
 void draw(Canvas canvas)
          Draw in its bounds (set via setBounds) respecting optional effects such as alpha (set via setAlpha) and color filter (set via setColorFilter).
 int getAlpha()
          Returns the alpha value of this drawable's color.
 int getChangingConfigurations()
          Return a mask of the configuration parameters for which this drawable mau change, requiring that it be re-created.
 Drawable.ConstantState getConstantState()
           
 int getOpacity()
          Return the opacity/transparency of this Drawable.
 void inflate(Resources r, XmlPullParser parser, AttributeSet attrs)
           
 void setAlpha(int alpha)
          Sets the color's alpha value.
 void setColorFilter(ColorFilter colorFilter)
          Setting a color filter on a ColorDrawable has no effect.
 
Methods inherited from class android.graphics.drawable.Drawable
clearColorFilter, copyBounds, copyBounds, createFromPath, createFromStream, createFromXml, createFromXmlInner, getBounds, getCurrent, getIntrinsicHeight, getIntrinsicWidth, getLevel, getMinimumHeight, getMinimumWidth, getPadding, getState, getTransparentRegion, inflateWithAttributes, invalidateSelf, isStateful, isVisible, 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()
Description copied from class: Drawable
Return a mask of the configuration parameters for which this drawable mau change, requiring that it be re-created. The default implementation returns whatever was provided through Drawable.setChangingConfigurations(int) or 0 by default. Subclasses may extend this to or in the changing configurations of any other drawables they hold.

Overrides:
getChangingConfigurations in class Drawable
Returns:
Returns a mask of the changing configuration parameters, as defined by Configuration.
See Also:
Configuration

draw

public void draw(Canvas canvas)
Description copied from class: Drawable
Draw in its bounds (set via setBounds) respecting optional effects such as alpha (set via setAlpha) and color filter (set via setColorFilter).

Specified by:
draw in class Drawable
Parameters:
canvas - The canvas to draw into

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 Drawable
Parameters:
alpha - The alpha value to set, between 0 and 255.

setColorFilter

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

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

getOpacity

public int getOpacity()
Description copied from class: Drawable
Return the opacity/transparency of this Drawable. The returned value is one of the abstract format constants in PixelFormat: PixelFormat.UNKNOWN, PixelFormat.TRANSLUCENT, PixelFormat.TRANSPARENT, or PixelFormat.OPAQUE.

Generally a Drawable should be as conservative as possible with the value it returns. For example, if it contains multiple child drawables and only shows one of them at a time, if only one of the children is TRANSLUCENT and the others are OPAQUE then TRANSLUCENT should be returned. You can use the method Drawable.resolveOpacity(int, int) to perform a standard reduction of two opacities to the appropriate single output.

Note that the returned value does not take into account a custom alpha or color filter that has been applied by the client through the Drawable.setAlpha(int) or Drawable.setColorFilter(android.graphics.ColorFilter) methods.

Specified by:
getOpacity in class Drawable
Returns:
int The opacity class of the Drawable.
See Also:
PixelFormat

inflate

public void inflate(Resources r,
                    XmlPullParser parser,
                    AttributeSet attrs)
             throws XmlPullParserException,
                    IOException
Overrides:
inflate in class Drawable
Throws:
XmlPullParserException
IOException

getConstantState

public Drawable.ConstantState getConstantState()
Overrides:
getConstantState in class Drawable

Build 1.0_r1(from source)

Please submit a feedback, bug or feature