The gradient drawable is defined using the <gradient> tag as a child node in the shape drawable definition.
Each gradient drawable requires at least one StartColor and EndColor property, and an optional Middlecolor attribute is supported. By using the Type property, you can define a gradient as one of the following types:
Linear: This is the default gradient type, which shows a direct color transition from StartColor to EndColor, as defined by the Angle property.
Radiation: Draws a circular gradient from StartColor to EndColor from the outer boundary of the shape to the center.
Scan: Draws a sweep gradient that transitions from startcolor to endcolor along the outer bounds of the parent shape (usually a ring).
1. Create a new drawable folder under Res.
2. Create a new XML file under the Drawable folder.
3. Reference this file in the Bacground attribute of the component.
Here are the linear codes and effects:
<?xml version= "1.0" encoding= "Utf-8"? ><shape xmlns:android= "Http://schemas.android.com/apk/res/android" android:shape= "Rectangle" android:uselevel= "false" > <gradient android:startcolor= " #ffffff " android:endcolor=" #ffffff " android:centercolor=" #000000 " android:uselevel=" false " Android:type= "linear" android:angle= "/></shape>"
Radiation gradient Ellipse
<?xml version= "1.0" encoding= "Utf-8"? ><shape xmlns:android= "Http://schemas.android.com/apk/res/android" android:shape= "Oval" android:uselevel= "false" > <gradient android:type= "Radial" android:startcolor= "#ffffff" android:endcolor= "#ffffff" android:centercolor= "#000000" Android : Uselevel= "false" android:gradientradius= "/></shape>"
Scan gradients:
<?xml version= "1.0" encoding= "Utf-8"? ><shape xmlns:android= "Http://schemas.android.com/apk/res/android" android:shape= "Ring" android:uselevel= "false" android:innerradiusratio= "3" android: thicknessratio= "8" > <gradient android:startcolor= "#ffffff" android:endcolor= "#ffffff" android:centercolor= "#000000" android:uselevel= "false" android:type= "sweep" /> < /shape><!--Scan the gradient ellipse--