Build 1.0_r1(from source)

android.graphics.drawable
Class BitmapDrawable

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

public class BitmapDrawable
extends Drawable


Nested Class Summary
(package private) static class BitmapDrawable.BitmapState
           
 
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
BitmapDrawable()
           
BitmapDrawable(Bitmap bitmap)
           
BitmapDrawable(InputStream is)
           
BitmapDrawable(String filepath)
           
 
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).
 Bitmap getBitmap()
           
 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 getGravity()
          Get the gravity used to position/stretch the bitmap within its bounds.
 int getIntrinsicHeight()
          Return the intrinsic height of the underlying drawable object.
 int getIntrinsicWidth()
          Return the intrinsic width of the underlying drawable object.
 int getOpacity()
          Return the opacity/transparency of this Drawable.
 Paint getPaint()
           
 Shader.TileMode getTileModeX()
           
 Shader.TileMode getTileModeY()
           
 void inflate(Resources r, XmlPullParser parser, AttributeSet attrs)
           
protected  void onBoundsChange(Rect bounds)
          Override this in your subclass to change appearance if you recognize the specified state.
 void setAlpha(int alpha)
          Specify an alpha value for the drawable.
 void setAntiAlias(boolean aa)
           
 void setColorFilter(ColorFilter cf)
          Specify an optional colorFilter for the drawable.
 void setDither(boolean dither)
          Set to true to have the drawable dither its colors when drawn to a device with fewer than 8-bits per color component.
 void setFilterBitmap(boolean filter)
          Set to true to have the drawable filter its bitmap when scaled or rotated (for drawables that use bitmaps).
 void setGravity(int gravity)
          Set the gravity used to position/stretch the bitmap within its bounds.
 void setTileModeX(Shader.TileMode mode)
           
 void setTileModeXY(Shader.TileMode xmode, Shader.TileMode ymode)
           
 void setTileModeY(Shader.TileMode mode)
           
 
Methods inherited from class android.graphics.drawable.Drawable
clearColorFilter, copyBounds, copyBounds, createFromPath, createFromStream, createFromXml, createFromXmlInner, getBounds, getCurrent, getLevel, getMinimumHeight, getMinimumWidth, getPadding, getState, getTransparentRegion, inflateWithAttributes, invalidateSelf, isStateful, isVisible, onLevelChange, onStateChange, resolveOpacity, scheduleSelf, setBounds, setBounds, setCallback, setChangingConfigurations, setColorFilter, setLevel, setState, setVisible, unscheduleSelf
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BitmapDrawable

public BitmapDrawable()

BitmapDrawable

public BitmapDrawable(Bitmap bitmap)

BitmapDrawable

public BitmapDrawable(String filepath)

BitmapDrawable

public BitmapDrawable(InputStream is)
Method Detail

getPaint

public final Paint getPaint()

getBitmap

public final Bitmap getBitmap()

getGravity

public int getGravity()
Get the gravity used to position/stretch the bitmap within its bounds. See android.view.Gravity

Returns:
the gravity applied to the bitmap

setGravity

public void setGravity(int gravity)
Set the gravity used to position/stretch the bitmap within its bounds. See android.view.Gravity

Parameters:
gravity - the gravity

setAntiAlias

public void setAntiAlias(boolean aa)

setFilterBitmap

public void setFilterBitmap(boolean filter)
Description copied from class: Drawable
Set to true to have the drawable filter its bitmap when scaled or rotated (for drawables that use bitmaps). If the drawable does not use bitmaps, this call is ignored. This can improve the look when scaled or rotated, but also slows down the drawing.

Overrides:
setFilterBitmap in class Drawable

setDither

public void setDither(boolean dither)
Description copied from class: Drawable
Set to true to have the drawable dither its colors when drawn to a device with fewer than 8-bits per color component. This can improve the look on those devices, but can also slow down the drawing a little.

Overrides:
setDither in class Drawable

getTileModeX

public Shader.TileMode getTileModeX()

getTileModeY

public Shader.TileMode getTileModeY()

setTileModeX

public void setTileModeX(Shader.TileMode mode)

setTileModeY

public final void setTileModeY(Shader.TileMode mode)

setTileModeXY

public void setTileModeXY(Shader.TileMode xmode,
                          Shader.TileMode ymode)

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

onBoundsChange

protected void onBoundsChange(Rect bounds)
Description copied from class: Drawable
Override this in your subclass to change appearance if you recognize the specified state.

Overrides:
onBoundsChange in class Drawable

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

setAlpha

public void setAlpha(int alpha)
Description copied from class: Drawable
Specify an alpha value for the drawable. 0 means fully transparent, and 255 means fully opaque.

Specified by:
setAlpha in class Drawable

setColorFilter

public void setColorFilter(ColorFilter cf)
Description copied from class: Drawable
Specify an optional colorFilter for the drawable. Pass null to remove any filters.

Specified by:
setColorFilter in class Drawable

inflate

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

getIntrinsicWidth

public int getIntrinsicWidth()
Description copied from class: Drawable
Return the intrinsic width of the underlying drawable object. Returns -1 if it has no intrinsic width, such as with a solid color.

Overrides:
getIntrinsicWidth in class Drawable

getIntrinsicHeight

public int getIntrinsicHeight()
Description copied from class: Drawable
Return the intrinsic height of the underlying drawable object. Returns -1 if it has no intrinsic height, such as with a solid color.

Overrides:
getIntrinsicHeight in class Drawable

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

getConstantState

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

Build 1.0_r1(from source)

Please submit a feedback, bug or feature