Please note that the contents of this offline web site may be out of date. To access the most recent documentation visit the online version .
Note that links that point to online resources are green in color and will open in a new window.
We would love it if you could give us feedback about this material by filling this form (You have to be online to fill it)
Android APIs
public class

PictureDrawable

extends Drawable
java.lang.Object
   ↳ android.graphics.drawable.Drawable
     ↳ android.graphics.drawable.PictureDrawable

Class Overview

Drawable subclass that wraps a Picture, allowing the picture to be used whereever a Drawable is supported.

Summary

Public Constructors
PictureDrawable ( Picture picture)
Construct a new drawable referencing the specified picture.
Public Methods
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 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.
Picture getPicture ()
Return the picture associated with the drawable.
void setAlpha (int alpha)
Specify an alpha value for the drawable.
void setColorFilter ( ColorFilter colorFilter)
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 setPicture ( Picture picture)
Associate a picture with this drawable.
[Expand]
Inherited Methods
From class android.graphics.drawable.Drawable
From class java.lang.Object

Public Constructors

public PictureDrawable ( Picture picture)

Added in API level 1

Construct a new drawable referencing the specified picture. The picture may be null.

Parameters
picture The picture to associate with the drawable. May be null.

Public Methods

public void draw ( Canvas canvas)

Added in API level 1

Draw in its bounds (set via setBounds) respecting optional effects such as alpha (set via setAlpha) and color filter (set via setColorFilter).

Parameters
canvas The canvas to draw into

public int getIntrinsicHeight ()

Added in API level 1

Return the intrinsic height of the underlying drawable object. Returns -1 if it has no intrinsic height, such as with a solid color.

public int getIntrinsicWidth ()

Added in API level 1

Return the intrinsic width of the underlying drawable object. Returns -1 if it has no intrinsic width, such as with a solid color.

public int getOpacity ()

Added in API level 1

Return the opacity/transparency of this Drawable. The returned value is one of the abstract format constants in PixelFormat : UNKNOWN , TRANSLUCENT , TRANSPARENT , or 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 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 setAlpha(int) or setColorFilter(ColorFilter) methods.

Returns
  • int The opacity class of the Drawable.

public Picture getPicture ()

Added in API level 1

Return the picture associated with the drawable. May be null.

Returns
  • the picture associated with the drawable, or null.

public void setAlpha (int alpha)

Added in API level 1

Specify an alpha value for the drawable. 0 means fully transparent, and 255 means fully opaque.

public void setColorFilter ( ColorFilter colorFilter)

Added in API level 1

Specify an optional colorFilter for the drawable. Pass null to remove any filters.

public void setDither (boolean dither)

Added in API level 1

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.

public void setFilterBitmap (boolean filter)

Added in API level 1

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.

public void setPicture ( Picture picture)

Added in API level 1

Associate a picture with this drawable. The picture may be null.

Parameters
picture The picture to associate with the drawable. May be null.