android 渐变drawable
来源:互联网 发布:篮球火 知乎 编辑:程序博客网 时间:2024/06/05 23:39
渐变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><!-- 扫描渐变的椭圆 -->
2 0
- android 渐变drawable
- Android drawable 渐变色
- Android Shape Drawable Resources TextView渐变 背景色 圆角
- Android Shape Drawable Resources TextView渐变 背景色 圆角
- Android 使用drawable xml文件代码绘制渐变图形,使用LayerList绘制复杂圆形
- Android Shape Drawable 静态使用和动态使用(圆角,渐变实现)
- android.graphics.drawable.Drawable
- android drawable Transition Drawable
- Android drawable
- Android Drawable
- android drawable
- Android Drawable
- Android Drawable
- Android Drawable
- android drawable
- Android Drawable
- android drawable
- Android Drawable
- 十二:微信公众帐号的类型(普通和会议)
- 黑马高新技术 注解篇
- 赛马问题
- 网络数据包格式及位置+简单嗅探器
- hdu 1022 Train Problem I(栈的应用+STL)
- android 渐变drawable
- Codeforces Round #260(Div2) Problem D. A Lot of Games
- Tabhost与activitygroup并用
- 探索MFC笔记——消息映射
- Android Makefile 编写总结
- 学习敏捷开发,party_bid故事卡2---活动报名
- 数据结构(python版)之一:线性表
- krpano 教程 - 常用actions说明
- Arcpy 合并一个文件夹下的FileGDB