Android Guides | Samples

Android.Graphics.Drawables.BitmapDrawable Class

A Drawable that wraps a bitmap and can be tiled, stretched, or aligned.

See Also: BitmapDrawable

Syntax

[Android.Runtime.Register("android/graphics/drawable/BitmapDrawable", DoNotGenerateAcw=true)]
public class BitmapDrawable : Drawable

Remarks

A Drawable that wraps a bitmap and can be tiled, stretched, or aligned. You can create a BitmapDrawable from a file path, an input stream, through XML inflation, or from a Bitmap object.

It can be defined in an XML file with the <bitmap> element. For more information, see the guide to Drawable Resources.

Also see the Bitmap class, which handles the management and transformation of raw bitmap graphics, and should be used when drawing to a Canvas.

[Android Documentation]

Requirements

Namespace: Android.Graphics.Drawables
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 1

The members of Android.Graphics.Drawables.BitmapDrawable are listed below.

See Also: Drawable

Public Constructors

Create an empty drawable, not dealing with density.
Create an empty drawable, setting initial target density based on the display metrics of the resources.
Create drawable from a bitmap, not dealing with density.
Create a drawable by decoding a bitmap from the given input stream.
Create a drawable by opening a given file path and decoding the bitmap.
Create drawable from a bitmap, setting initial target density based on the display metrics of the resources.
Create a drawable by decoding a bitmap from the given input stream.
Create a drawable by opening a given file path and decoding the bitmap.

Protected Constructors

A constructor used when creating managed representations of JNI objects; called by the runtime.

Public Properties

[read-only]
BitmapBitmap. Returns the bitmap used by this drawable to render.
GravityGravityFlags. Get the gravity used to position/stretch the bitmap within its bounds.
[read-only]
HasAntiAliasBoolean. Indicates whether anti-aliasing is enabled for this drawable.
[read-only]
HasMipMapBoolean. Indicates whether the mipmap hint is enabled on this drawable's bitmap.
[read-only]
IsAutoMirroredBoolean. Tells if this Drawable will be automatically mirrored when its layout direction is RTL right-to-left.
[read-only]
override
OpacityInt32. Return the opacity/transparency of this Drawable.
[read-only]
PaintPaint. Returns the paint used to render this drawable.
TileModeXShader+TileMode. Indicates the repeat behavior of this drawable on the X axis.
TileModeYShader+TileMode. Indicates the repeat behavior of this drawable on the Y axis.

Protected Properties

[read-only]
override
ThresholdClassIntPtr. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.
[read-only]
override
ThresholdTypeType. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Public Methods

override
Draw(Canvas)
Draw in its bounds (set via setBounds) respecting optional effects such as alpha (set via setAlpha) and color filter (set via setColorFilter).
override
GetConstantState() : Drawable+ConstantState
Return a NoType:android/graphics/drawable/Drawable$ConstantState;Href=../../../../reference/android/graphics/drawable/Drawable.ConstantState.html instance that holds the shared state of this Drawable.
override
SetAlpha(Int32)
Specify an alpha value for the drawable. 0 means fully transparent, and 255 means fully opaque.
SetAntiAlias(Boolean)
Enables or disables anti-aliasing for this drawable.
override
SetColorFilter(ColorFilter)
Specify an optional color filter for the drawable.
SetMipMap(Boolean)
Enables or disables the mipmap hint for this drawable's bitmap.
SetTargetDensity(Canvas)
Set the density scale at which this drawable will be rendered.
SetTargetDensity(DisplayMetrics)
Set the density scale at which this drawable will be rendered.
SetTargetDensity(Int32)
Set the density at which this drawable will be rendered.
SetTileModeXY(Shader+TileMode, Shader+TileMode)
Sets the repeat behavior of this drawable on both axis.