GradientDrawable

Class of android.graphics.drawable · GradientDrawable.java · Android's reference

public class GradientDrawable extends Drawable

GradientDrawable ← Drawable

A shape (rectangle, oval, line or ring) filled with a color or a gradient, with an optional stroke.

Nested types

Page 1 2

Fields

public static final int RECTANGLE = 0 source
public static final int OVAL = 1 source
public static final int LINE = 2 source
public static final int RING = 3 source
public static final int LINEAR_GRADIENT = 0 source
public static final int RADIAL_GRADIENT = 1 source
public static final int SWEEP_GRADIENT = 2 source

Constructors

public GradientDrawable() source
public GradientDrawable(Orientation orientation, int[] colors) source

Methods

public void inflate(android.content.res.Resources r, org.xmlpull.v1.XmlPullParser parser, android.util.AttributeSet attrs, android.content.res.Resources.Theme theme) throws org.xmlpull.v1.XmlPullParserException, java.io.IOException source

a <shape>: its kind, then its solid, stroke, corners, padding, size and gradient elements

public ConstantState getConstantState() source

a resource's, else one of a copy of the shape, its fill, stroke, corners, gradient, size and padding

public boolean getPadding(Rect out) source
public void setShape(int shape) source
public int getShape() source
public void setSize(int width, int height) source
public void setColor(int argb) source
public void setColor(ColorStateList colorStateList) source
public ColorStateList getColor() source
public void setColors(int[] colors) source
public void setColors(int[] colors, float[] offsets) source

the gradient's colors, and each one's position from 0 to 1 (null for evenly spaced)

public int[] getColors() source
public void setOrientation(Orientation orientation) source
public Orientation getOrientation() source
public void setGradientType(int gradient) source
public int getGradientType() source
public void setGradientRadius(float gradientRadius) source
public float getGradientRadius() source
public void setGradientCenter(float x, float y) source

the center of a radial or sweep gradient, as fractions of the bounds

public float getGradientCenterX() source
public float getGradientCenterY() source
public void setCornerRadius(float radius) source
public float getCornerRadius() source
public void setCornerRadii(float[] radii) source
public float[] getCornerRadii() source
public void setStroke(int width, int color) source
public void setStroke(int width, ColorStateList colorStateList) source

Page 1 2


Made from ScarletNX's Sail at 166ad3910f80. The framework is ScarletNX's (GPL-3.0-or-later); the parts that follow the Android Open Source Project's sources (Apache-2.0) say so in their files.