public class GradientColor extends ComplexColor
VectorDrawable
.
GradientColor
s are created from XML resource files defined in the
"color" subdirectory directory of an application's resource directory. The XML file contains
a single "gradient" element with a number of attributes and elements inside. For example:
<gradient xmlns:android="http://schemas.android.com/apk/res/android"> <android:startColor="?android:attr/colorPrimary"/> <android:endColor="?android:attr/colorControlActivated"/> <.../> <android:type="linear"/> </gradient>This can describe either a
LinearGradient
,
RadialGradient
, or SweepGradient
.
Note that different attributes are relevant for different types of gradient.
For example, android:gradientRadius is only applied to RadialGradient.
android:centerX and android:centerY are only applied to SweepGradient or RadialGradient.
android:startX, android:startY, android:endX and android:endY are only applied to LinearGradient.
Also note if any color "item" element is defined, then startColor, centerColor and endColor will
be ignored.Modifier and Type | Method and Description |
---|---|
boolean |
canApplyTheme()
Returns whether a theme can be applied to this gradient color, which
usually indicates that the gradient color has unresolved theme
attributes.
|
static GradientColor |
createFromXml(Resources r,
XmlResourceParser parser,
Resources.Theme theme)
A public method to create GradientColor from a XML resource.
|
int |
getChangingConfigurations()
Returns a mask of the configuration parameters for which this gradient
may change, requiring that it be re-created.
|
ConstantState<ComplexColor> |
getConstantState()
Similar to ColorStateList, setup constant state and its factory.
|
int |
getDefaultColor()
For Gradient color, the default color is not very useful, since the gradient will override
the color information anyway.
|
Shader |
getShader()
The shader information will be applied to the native VectorDrawable's path.
|
GradientColor |
obtainForTheme(Resources.Theme t)
Returns an appropriately themed gradient color.
|
isStateful
public Shader getShader()
public static GradientColor createFromXml(Resources r, XmlResourceParser parser, Resources.Theme theme) throws XmlPullParserException, IOException
XmlPullParserException
IOException
public int getDefaultColor()
getDefaultColor
in class ComplexColor
public ConstantState<ComplexColor> getConstantState()
getConstantState
in class ComplexColor
public GradientColor obtainForTheme(Resources.Theme t)
obtainForTheme
in class ComplexColor
t
- the theme to applypublic int getChangingConfigurations()
getChangingConfigurations
in class ComplexColor
ActivityInfo
ActivityInfo
public boolean canApplyTheme()
canApplyTheme
in class ComplexColor