渐变Drawable它是使用<gradient>的标记的形状Drawable定义子节点的定义。

每个梯度Drawable求至少要有一个startColor和endColor属性,而且支持一个可选的middleColor属性。

通过使用type属性,能够把渐变定义为下面的某种类型:

线性:这是默认的渐变类型,它显示了依照angle属性定义的角度从startColor到endColor的直接颜色过渡。

辐射:从形状的外边界到中心绘制从startColor到endColor的圆形渐变。

扫描:绘制一个扫描渐变,它将沿着父形状(一般是一个圆环)的外边界从startColor到endColor进行过渡。

1.在res下新建drawable目录。

2.在drawable目录下新建xml文件。

3.在组件的bacground属性里引用此文件。

以下是线性的代码和效果:

<?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="45"
/>
</shape>

辐射渐变的椭圆

<?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="300"
/> </shape>

扫描渐变:

<?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>
<!-- 扫描渐变的椭圆 -->

watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvaG93bGFh/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="">

版权声明:本文博客原创文章,博客,未经同意,不得转载。

最新文章

  1. Xcode调试技巧(断点和重构)
  2. WebStorm设置字体和颜色
  3. PAT (Basic Level) Practise:1006. 换个格式输出整数
  4. [RxJS] Handling Multiple Streams with Merge
  5. ubuntu12.04安装openjdk-7
  6. Python 学习笔记12
  7. C语言中无符号数和有符号数之间的运算
  8. getElementById 用法的一个技巧
  9. P1836 【数页码_NOI导刊2011提高(04)】
  10. mongoDB 文档操作_删
  11. Xml序列化 详解
  12. typescript 关于class属性类型定义被属性默认值覆盖的问题及解决方式
  13. Git 转载
  14. Gym 100342J Triatrip (求三元环的数量) (bitset优化)
  15. Android7.0手机程序保活(附源码下载)
  16. Mysql的命令总结
  17. vs get set快捷键
  18. git博客好的例子
  19. 推荐系统-07-lambda架构
  20. python装饰器、继承、元类、mixin,四种給类动态添加类属性和方法的方式(一)

热门文章

  1. unity3d由于Camera.main.transform报空引用错误的解决方案
  2. jQuery获取url参数值
  3. (九)通过几段代码,理清angularJS中的$injector、$rootScope和$scope的概念和关联关系
  4. [WPF]Binding的Converter和Validator
  5. 简介支持向量机热门(认识SVM三位置)
  6. Hadoop-2.2.0中国文档—— MapReduce 下一代 -- 公平调度
  7. 编译gRPC
  8. hibernate 批量处理数据
  9. 用MODELLER构建好模型后对loop区域进行自动的优化过程
  10. lua 远程调试 【zeroBrane 使用mobdebug】(good转)