android之shape的说明
来源:互联网 发布:龙卷风网络收音机 mac 编辑:程序博客网 时间:2024/06/06 02:29
ShapeDrawable经常会用到,以前都是现用现查,这里做一个简单说明,以备以后查询
Shape一共有四种类型,属性基本上都可以通用
1, 矩形
<?xml version="1.0" encoding="utf-8"?><!-- 矩形--><shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <!-- 四个角的角度 radius : 为四个角设置相同的角度,优先低,会被下方面的四个方法也取代 topLeftRadius : 左上角角度 topRightRadius : 右上角角度 bottomLeftRadius : 左下角角度 bottomRightRadius : 右下角角度 --> <corners android:radius ="4dp" android:topLeftRadius = "12dp" android:topRightRadius ="12dp" android:bottomLeftRadius = "12dp" android:bottomRightRadius = "12dp"/> <!-- 渐变填充,与下方的solid互斥 angle : 渐变的角度,其值必须为45度的倍数,0 表示从左到右,90表示从上到下 centerX : 渐变中心点的横坐标 centerY : 渐变中心点的纵坐标,渐变中心点,会影响渐变的效果 startColor : 渐变开始颜色 centerColor : 渐变中间颜色(可以不设置) endColor : 渐变结束颜色 gradientRadius : 渐变半径,仅当下方的type为radial时有效 type : 渐变类别 linear(线性) radial(圆) sweep(发射) useLevel : 一般为false,作为 StateListDrawable为true --> <gradient android:angle="45" android:centerX="20" android:centerY="20" android:startColor="#ff4433" android:centerColor="#ee44dd" android:endColor="#004433" android:gradientRadius="10" android:type="radial" android:useLevel="false" /> <!-- 纯色填充,与上面方的渐变填充互斥 <solid android:color="#ff4433"/>--> <!-- 描边 width : 描边的宽度,越大边越宽 color : 描边的颜色 dashWidth : 组成虚线的线段的宽 (可为空,为空画的是实线) dashGap : 虚线线段之间的距离 (可为空,此值与上面的值有一个为0或为空,则为实线) --> <stroke android:width="2dp" android:color="#004433" android:dashWidth="2dp" android:dashGap="2dp"/> <!-- 它表示不是shape的空白,而是包含它的view的空白 --> <padding android:top="10dp" android:left="10dp" android:right="10dp" android:bottom="10dp"/> <!-- 一般情况下不会设置 --> <size android:width="30dp" android:height="20dp" /></shape>2, 椭圆
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval"> <!-- 渐变填充,与下方的solid互斥 angle : 渐变的角度,其值必须为45度的倍数,0 表示从左到右,90表示从上到下 centerX : 渐变中心点的横坐标 centerY : 渐变中心点的纵坐标,渐变中心点,会影响渐变的效果 startColor : 渐变开始颜色 centerColor : 渐变中间颜色(可以不设置) endColor : 渐变结束颜色 gradientRadius : 渐变半径,仅当下方的type为radial时有效 type : 渐变类别 linear(线性) radial(圆) sweep(发射) useLevel : 一般为false,作为 StateListDrawable为true --> <gradient android:angle="45" android:startColor="#ff4433" android:centerColor="#ee44dd" android:endColor="#004433" android:gradientRadius="100" android:type="linear" android:useLevel="false" /> <!-- 纯色填充,与上面方的渐变填充互斥 <solid android:color="#ff4433"/>--> <!-- 描边 width : 描边的宽度,越大边越宽 color : 描边的颜色 dashWidth : 组成虚线的线段的宽 (可为空,为空画的是实线) dashGap : 虚线线段之间的距离 (可为空,此值与上面的值有一个为0或为空,则为实线) --> <stroke android:width="2dp" android:color="#004433" android:dashWidth="2dp" android:dashGap="2dp"/></shape>
3,线
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="line"> <!-- 渐变填充,与下方的solid互斥 angle : 渐变的角度,其值必须为45度的倍数,0 表示从左到右,90表示从上到下 centerX : 渐变中心点的横坐标 centerY : 渐变中心点的纵坐标,渐变中心点,会影响渐变的效果 startColor : 渐变开始颜色 centerColor : 渐变中间颜色(可以不设置) endColor : 渐变结束颜色 gradientRadius : 渐变半径,仅当下方的type为radial时有效 type : 渐变类别 linear(线性) radial(圆) sweep(发射) useLevel : 一般为false,作为 StateListDrawable为true --> <gradient android:angle="45" android:centerX="20" android:centerY="20" android:startColor="#ff4433" android:centerColor="#ee44dd" android:endColor="#004433" android:gradientRadius="10" android:type="radial" android:useLevel="false" /> <!-- 纯色填充,与上面方的渐变填充互斥 <solid android:color="#ff4433"/>--> <!-- 描边 width : 描边的宽度,越大边越宽 color : 描边的颜色 dashWidth : 组成虚线的线段的宽 (可为空,为空画的是实线) dashGap : 虚线线段之间的距离 (可为空,此值与上面的值有一个为0或为空,则为实线) --> <stroke android:width="2dp" android:color="#004433" android:dashWidth="2dp" android:dashGap="2dp"/></shape>4,环形
<?xml version="1.0" encoding="utf-8"?><!-- innerRadius : 圆环的内半径 thickness : 环的宽度 useLevel : 必须设置成false,否则无法达到需要的效果--><shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="ring" android:innerRadius="80dp" android:thickness="10dp" android:useLevel="false"> <!-- 渐变填充,与下方的solid互斥 angle : 渐变的角度,其值必须为45度的倍数,0 表示从左到右,90表示从上到下 centerX : 渐变中心点的横坐标 centerY : 渐变中心点的纵坐标,渐变中心点,会影响渐变的效果 startColor : 渐变开始颜色 centerColor : 渐变中间颜色(可以不设置) endColor : 渐变结束颜色 gradientRadius : 渐变半径,仅当下方的type为radial时有效 type : 渐变类别 linear(线性) radial(圆) sweep(发射) useLevel : 一般为false,作为 StateListDrawable为true--> <gradient android:angle="45" android:centerX="20" android:centerY="20" android:startColor="#ff4433" android:centerColor="#ee44dd" android:endColor="#004433" android:gradientRadius="10" android:type="radial" android:useLevel="false" /> <!-- 纯色填充,与上面方的渐变填充互斥 <solid android:color="#ff4433"/>--> <!-- 描边 width : 描边的宽度,越大边越宽 color : 描边的颜色 dashWidth : 组成虚线的线段的宽 (可为空,为空画的是实线) dashGap : 虚线线段之间的距离 (可为空,此值与上面的值有一个为0或为空,则为实线) --> <stroke android:width="2dp" android:color="#004433" android:dashWidth="2dp" android:dashGap="2dp"/></shape>
0 0
- android之shape的说明
- android:shape的说明
- Android中Shape的属性说明
- Android Shape Drawable 说明
- android之Shape的使用
- Android之shape的使用
- android之shape和selector和layer-list的(详细说明)
- Android中Shape的属性说明及其使用
- android界面设计之shape的使用
- Android开发之shape的使用
- Android之XML的shape使用
- Android开发之 shape的使用
- android UI之shape的基本用法
- android基础学习之shape的用法
- Android之的Shape图形使用
- Android02--Android之Shape的使用
- 有关shape文件的说明
- android UI 之shape
- android开发 自定义view实现黑白棋子游戏
- c#编码解码---间断更新中
- Jersey复杂案例 完整的增删改查Restful服务
- python匿名函数
- 神的回复,让一道jvm的题目瞬间简单,在中国,评论永远是最精彩的
- android之shape的说明
- union union all group by 优化一例
- 整装待发,重新出发,不放弃,这就是生活
- iOS 10 消息推送(UserNotifications)秘籍总结(一,二)
- mac下使用ll等指令
- bson json区别
- 最理想的正方形
- 中文乱码原因解析
- ETL系统增量抽取方案