<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<gradient
android:endColor="#000000"
android:startColor="#ffffff"
android:type="radial"
android:gradientRadius="200"
android:centerX="0.5"
android:centerY="0.5"
/>
</shape>
<gradient>
Specifies a gradient color for the shape.
attributes:
//渐变角度, Integer. The angle for the gradient, in degrees. 0 is left to right, 90 is bottom to top. It must be a multiple of 45. Default is 0.
// 当 =0 时 从左至右渐变, 当=90 时从下至上渐变
android:angle
Integer. The angle for the gradient, in degrees. 0 is left to right, 90 is bottom to top. It must be a multiple of 45. Default is 0.
android:centerX
Float. The relative X-position for the center of the gradient (0 - 1.0). Does not apply when android:type="linear"(其实官方文档并没有说明linear 无效,但实际linear上效果确定差别不太大。) 当 android:type="radial" 时,android:centerX="0" 及android:centerY="0" 表示左上角原点。
android:centerY
Float. The relative Y-position for the center of the gradient (0 - 1.0).
android:centerColor
Color. Optional color that comes between the start and end colors, as a hexadecimal value or color resource.
android:endColor
Color. The ending color, as a hexadecimal value or color resource.
android:gradientRadius
Float. The radius for the gradient. Only applied when android:type="radial".
android:startColor
Color. The starting color, as a hexadecimal value or color resource.
android:type
Keyword. The type of gradient pattern to apply. Valid values are:
Value
Description
"linear"
A linear gradient. This is the default.
"radial"
A radial gradient. The start color is the center color.
"sweep"
A sweeping line gradient.
android:useLevel
Boolean. "true" if this is used as a LevelListDrawable.
其它参考文章:
http://blog.csdn.net/jamesliulyc/article/details/6433168
http://my.oschina.net/xesam/blog/92049