shape属性参考
来源:互联网 发布:绿色建筑设计软件 编辑:程序博客网 时间:2024/06/05 11:54
上两篇讲了布局控件一些常用的属性介绍。今天讲下shape。
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <corners android:radius="10dp"/> <solid android:color="@android:color/black"/> <stroke android:color="@color/colorAccent" android:width="1px"/></shape>
shape有几种形状:
android:shape=”rectangle|line|oval|ring”// 矩形、线条、椭圆、圆环
shape有几种属性:
corners:圆角半径
gradient:颜色渐变
padding:内边距
size:尺寸大小
solid:填充颜色
stroke:边框
下面将一一介绍各个属性都有哪些参数可以设置:
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="ring" android:useLevel="false"// 必须为false,否则无法显示 android:innerRadiusRatio="2.5"// 比率=圆环宽度/圆环内径 android:innerRadius="20dp"// 圆环内径 android:thickness="10dp"// 圆环厚度 android:thicknessRatio="2.5"// 比率=圆环宽度/圆环厚度 android:tint="@color/colorAccent"// shape颜色,solid颜色会失效 >
<corners android:bottomLeftRadius="10dp"// 坐下角 android:bottomRightRadius="10dp"// 右下角 android:topLeftRadius="10dp"// 左上角 android:topRightRadius="10dp"/>// 右上角 <corners android:radius="10dp" /> 这两段代码效果是一样的,都是表示圆角半径为10dp。
<gradient android:angle="45"// 渐变角度,只能是45的倍数 android:startColor=""// 渐变的初始颜色 android:endColor=""// 渐变的终止颜色 android:centerColor=""// 渐变中心的颜色 android:centerX="50%"// 渐变中点的x坐标:float:0~1 android:centerY="50%"// 渐变中点的y坐标:float:0~1 android:gradientRadius="0dp"// 渐变半径,type=radial android:type="sweep|radial|linear"// 渐变效果:扫描、溅射、线性 android:useLevel="true|false"/>// 暂未用过
<padding // 内边距 android:bottom="10dp" android:left="10dp" android:right="10dp" android:top="10dp"/>
<size // 设置图形固定大小 android:height="10dp" android:width="200dp"/>
<solid // 设置填充图形的颜色 android:color="@android:color/black"/>
<stroke // 设置线条边框 android:color="@android:color/black" android:width="1px"// 边框宽度 android:dashGap="10dp"// 虚线间隙 android:dashWidth="10dp"/> // 虚线宽度
注意:当shape=”line”时,View的android:layout_height(size的height)值要比stroke的width大,否则不会显示;当画虚线时,需要关闭硬件加速,可再View的布局中添加android:layerType=”software”,当然还有其他方法。
阅读全文
0 0
- shape属性参考
- shape 属性
- Shape属性:
- Shape 属性形状控件Shape
- android <shape>各个属性
- android:shape属性详解
- Shape的gradient属性
- android shape的属性
- Android shape 属性介绍
- shape属性详解
- android:shape 属性
- android:shape属性详解
- android:shape属性详解
- Android shape属性介绍
- Android Shape 属性详解
- android:shape属性详解
- android shape 的属性
- Android:shape属性大全!!!
- linux计划任务crond服务
- ssm整合练习 -- day01
- 开发工具系列(一):Btrace——线上Debug工具
- Redis 数据类型之List类型
- 点和解析式有关的操作
- shape属性参考
- [系分] 设计对象的原则
- PHP中new self()和new static()的区别探究
- jQuery Mobile 表格
- 带有一键清空功能的EditText
- CentOs 7 相关命令
- studio2.3app签名打包安装失败,找不到签名证书。
- HttpClient 实现文件的上传
- Android xmpp开发 asmack获取离线在线添加好友讯息 及 好友上线下线通知