android 渐变drawable
2024-08-27 18:50:35
渐变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="">
版权声明:本文博客原创文章,博客,未经同意,不得转载。
最新文章
- Xcode调试技巧(断点和重构)
- WebStorm设置字体和颜色
- PAT (Basic Level) Practise:1006. 换个格式输出整数
- [RxJS] Handling Multiple Streams with Merge
- ubuntu12.04安装openjdk-7
- Python 学习笔记12
- C语言中无符号数和有符号数之间的运算
- getElementById 用法的一个技巧
- P1836 【数页码_NOI导刊2011提高(04)】
- mongoDB 文档操作_删
- Xml序列化 详解
- typescript 关于class属性类型定义被属性默认值覆盖的问题及解决方式
- Git 转载
- Gym 100342J Triatrip (求三元环的数量) (bitset优化)
- Android7.0手机程序保活(附源码下载)
- Mysql的命令总结
- vs get set快捷键
- git博客好的例子
- 推荐系统-07-lambda架构
- python装饰器、继承、元类、mixin,四种給类动态添加类属性和方法的方式(一)
热门文章
- unity3d由于Camera.main.transform报空引用错误的解决方案
- jQuery获取url参数值
- (九)通过几段代码,理清angularJS中的$injector、$rootScope和$scope的概念和关联关系
- [WPF]Binding的Converter和Validator
- 简介支持向量机热门(认识SVM三位置)
- Hadoop-2.2.0中国文档—— MapReduce 下一代 -- 公平调度
- 编译gRPC
- hibernate 批量处理数据
- 用MODELLER构建好模型后对loop区域进行自动的优化过程
- lua 远程调试 【zeroBrane 使用mobdebug】(good转)