Android Guides | Samples

Android.Graphics.Drawables.ShapeDrawable Class

A Drawable object that draws primitive shapes.

See Also: ShapeDrawable

Syntax

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

Remarks

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]

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.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

[read-only]
override
OpacityInt32. Return the opacity/transparency of this Drawable.
[read-only]
PaintPaint. Returns the Paint used to draw the shape.
ShapeShape. Returns the Shape of this ShapeDrawable.

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).
GetShaderFactory() : ShapeDrawable+ShaderFactory
Returns the ShaderFactory used by this ShapeDrawable for requesting a Shader.
override
SetAlpha(Int32)
Set the alpha level for this drawable [0.
override
SetColorFilter(ColorFilter)
Specify an optional color filter for the drawable.
SetIntrinsicHeight(Int32)
Sets the intrinsic (default) height for this shape.
SetIntrinsicWidth(Int32)
Sets the intrinsic (default) width for this shape.
SetPadding(Rect)
Sets padding for this shape, defined by a Rect object.
SetPadding(Int32, Int32, Int32, Int32)
Sets padding for the shape.
SetShaderFactory(ShapeDrawable+ShaderFactory)
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).