关于shap gradient 属性参数

<?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


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值