Java android.graphics.drawable GradientDrawable fields, constructors, methods, implement or subclass

Example usage for Java android.graphics.drawable GradientDrawable fields, constructors, methods, implement or subclass

Introduction

In this page you can find the methods, fields and constructors for android.graphics.drawable GradientDrawable.

The text is from its open source code.

Field

intRECTANGLE
Shape is a rectangle, possibly with rounded corners
intOVAL
Shape is an ellipse
intLINEAR_GRADIENT
Gradient is linear (default.)
intRADIAL_GRADIENT
Gradient is circular.
intSWEEP_GRADIENT
Gradient is a sweep.

Constructor

GradientDrawable()
GradientDrawable(Orientation orientation, @ColorInt int[] colors)
Create a new gradient drawable given an orientation and an array of colors for the gradient.
GradientDrawable(@NonNull GradientState state, @Nullable Resources res)
Creates a new themed GradientDrawable based on the specified constant state.

Method

voiddraw(Canvas canvas)
ConstantStategetConstantState()
intgetIntrinsicHeight()
intgetIntrinsicWidth()
voidinvalidateSelf()
Use the current Callback implementation to have this Drawable redrawn.
Drawablemutate()
voidsetAlpha(int alpha)
voidsetBounds(int left, int top, int right, int bottom)
Specify a bounding rectangle for the Drawable.
voidsetColor(@ColorInt int argb)
Changes this drawable to use a single color instead of a gradient.
voidsetColor(@Nullable ColorStateList colorStateList)
Changes this drawable to use a single color state list instead of a gradient.
voidsetColorFilter(@Nullable ColorFilter colorFilter)
voidsetColorFilter(@ColorInt int color, @NonNull PorterDuff.Mode mode)
Specify a color and Porter-Duff mode to be the color filter for this drawable.
voidsetColors(@ColorInt int[] colors)
Sets the colors used to draw the gradient.
voidsetCornerRadii(@Nullable float[] radii)
Specifies radii for each of the 4 corners.
voidsetCornerRadius(float radius)
Specifies the radius for the corners of the gradient.
voidsetDither(boolean dither)
voidsetGradientCenter(float x, float y)
Sets the position of the center of the gradient as a fraction of the width and height.
voidsetGradientRadius(float gradientRadius)
Sets the radius of the gradient.
voidsetGradientType(@GradientType int gradient)
Sets the type of gradient used by this drawable.
voidsetOrientation(Orientation orientation)
Sets the orientation of the gradient defined in this drawable.
voidsetShape(@Shape int shape)

Sets the type of shape used to draw the gradient.

Note: changing this property will affect all instances of a drawable loaded from a resource.

voidsetSize(int width, int height)

Sets the size of the shape drawn by this drawable.

Note: changing this property will affect all instances of a drawable loaded from a resource.

voidsetStroke(int width, @ColorInt int color)

Set the stroke width and color for the drawable.

voidsetStroke(int width, ColorStateList colorStateList)

Set the stroke width and color state list for the drawable.

voidsetStroke(int width, @ColorInt int color, float dashWidth, float dashGap)

Set the stroke width and color for the drawable.

voidsetStroke(int width, ColorStateList colorStateList, float dashWidth, float dashGap)

Set the stroke width and color state list for the drawable.

voidsetUseLevel(boolean useLevel)
Sets whether this drawable's level property will be used to scale the gradient.