Android Guides | Samples

Android.Graphics.Drawables.ShapeDrawable Class

A Drawable object that draws primitive shapes.

See Also: ShapeDrawable


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


A Drawable object that draws primitive shapes. A ShapeDrawable takes a Shape object and manages its presence on the screen. If no Shape is given, then the ShapeDrawable will default to a RectShape.

Developer Guides

This object can be defined in an XML file with the <shape> element.

For more information about how to use ShapeDrawable, read the Canvas and Drawables document. For more information about defining a ShapeDrawable in XML, read the Drawable Resources document.

[Android Documentation]


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

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

See Also: Drawable

Public Constructors

ShapeDrawable constructor.
Creates a ShapeDrawable with a specified Shape.

Protected Constructors

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

Public Properties

OpacityInt32. Return the opacity/transparency of this Drawable.
PaintPaint. Returns the Paint used to draw the shape.
ShapeShape. Returns the Shape of this ShapeDrawable.

Protected Properties

ThresholdClassIntPtr. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.
ThresholdTypeType. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Public Methods

Draw in its bounds (set via setBounds) respecting optional effects such as alpha (set via setAlpha) and color filter (set via setColorFilter).
GetShaderFactory() : ShapeDrawable+ShaderFactory
Returns the ShaderFactory used by this ShapeDrawable for requesting a Shader.
Set the alpha level for this drawable [0.
Specify an optional color filter for the drawable.
Sets the intrinsic (default) height for this shape.
Sets the intrinsic (default) width for this shape.
Sets padding for this shape, defined by a Rect object.
SetPadding(Int32, Int32, Int32, Int32)
Sets padding for the shape.
Sets a ShaderFactory to which requests for a Shader object will be made.

Protected Methods

InflateTag(String, Resources, XmlReader, IAttributeSet) : Boolean
Subclasses override this to parse custom subelements.
OnDraw(Shape, Canvas, Paint)
Called from the drawable's draw() method after the canvas has been set to draw the shape at (0,0).