Android Guides | Samples

Android.Graphics.Drawables.GradientDrawable Class

A Drawable with a color gradient for buttons, backgrounds, etc.

See Also: GradientDrawable

Syntax

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

Remarks

A Drawable with a color gradient for buttons, backgrounds, etc.

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

[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.GradientDrawable are listed below.

See Also: Drawable

Public Constructors

Create a new gradient drawable given an orientation and an array of colors for the gradient.

Protected Constructors

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

Public Properties

[read-only]
GradientRadiusSingle. Returns the radius of the gradient in pixels.
[read-only]
override
OpacityInt32. Return the opacity/transparency of this Drawable.

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).
GetOrientation() : GradientDrawable+Orientation
Returns the orientation of the gradient defined in this drawable.
override
SetAlpha(Int32)
Specify an alpha value for the drawable. 0 means fully transparent, and 255 means fully opaque.
SetColor(ColorStateList)
Changes this drawable to use a single color state list instead of a gradient.
SetColor(Int32)
override
SetColorFilter(ColorFilter)
Specify an optional color filter for the drawable.
SetColors(Int32[])
Sets the colors used to draw the gradient.
SetCornerRadii(Single[])
SetCornerRadius(Single)
SetGradientCenter(Single, Single)
SetGradientRadius(Single)
SetGradientType(GradientType)
SetOrientation(GradientDrawable+Orientation)
SetShape(ShapeType)
SetSize(Int32, Int32)
SetStroke(Int32, ColorStateList)
SetStroke(Int32, Color)
SetStroke(Int32, ColorStateList, Single, Single)
SetStroke(Int32, Color, Single, Single)
SetUseLevel(Boolean)