Android shape的使用笔记
来源:互联网 发布:arduino 单片机 编辑:程序博客网 时间:2024/05/19 17:56
shape是外形资源,用于设定形状,是一种非常有意思的资源,也是非常强大的资源,通过外形资源可以使控件四个角便圆;也可以设置控件内容的边界等等,shape标签中主要使用<gradient>、<padding>、<stroke>、<corners>、<solid>、<size>这几个常用子标签。
在定义外形资源时,需要使用<shape>标签的android:shape属性指定要绘制的形状。
主要有四种:
rectangle:矩形
oval:椭圆
line:直线
ring:圆环
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android"android:shape="rectangle"><!--定义渐变色(从左下角到右上角绘制渐变色) --><gradient android:startColor="#FFFF0000" android:endColor="#80FF00FF"android:angle="45" /><!--定义控件内容到边界的距离(到四条边界的距离都是7) --><padding android:left="7dp" android:top="7dp" android:right="7dp"android:bottom="7dp" /><!--定义边界框线(边框线宽度为2,颜色为白色) --><stroke android:width="2dp" android:color="#FFF" /><!--定义圆角(圆角半径为8) --><corners android:radius="8dp" /></shape>
一个全一点的例子
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android" > <!-- 圆角 --> <corners android:radius="9dp" android:topLeftRadius="2dp" android:topRightRadius="2dp" android:bottomLeftRadius="2dp" android:bottomRightRadius="2dp"/><!-- 设置圆角半径 --> <!-- 渐变 --> <gradient android:startColor="@android:color/white" android:centerColor="@android:color/black" android:endColor="@android:color/black" android:useLevel="true" android:angle="45" android:type="radial" android:centerX="0" android:centerY="0" android:gradientRadius="90"/> <!-- 间隔 --> <padding android:left="2dp" android:top="2dp" android:right="2dp" android:bottom="2dp"/><!-- 各方向的间隔 --> <!-- 大小 --> <size android:width="50dp" android:height="50dp"/><!-- 宽度和高度 --> <!-- 填充 --> <solid android:color="@android:color/white"/><!-- 填充的颜色 --> <!-- 描边 --> <stroke android:width="2dp" android:color="@android:color/black" android:dashWidth="1dp" android:dashGap="2dp"/> </shape>
0 0
- Android shape的使用笔记
- android shape使用笔记
- Android笔记----Shape标签使用
- android:shape的使用
- android:shape的使用
- android:shape的使用
- android:shape的使用
- android:shape的使用
- android:shape的使用
- android:shape的使用
- android:shape的使用
- android:shape的使用
- android:shape的使用
- android shape的使用
- android:shape的使用
- android:shape的使用
- android:shape的使用
- android:shape的使用
- 模拟快递100请求 通过快递单号获取物流信息
- 多线程操作之线程概念
- mysql查询所有记录,并去掉重复的记录
- SDWebImage内部实现过程
- 英国MBA专业
- Android shape的使用笔记
- windows下Eclipse JDK环境变量配置 Tomcat配置
- Servlet的认识
- opencv1.0-vc6-win7 视屏流
- linux下kodi没有声音的解决
- iOS8 Core Image In Swift:自动改善图像以及内置滤镜的使用
- TCP的拥塞控制和流量控制的比较
- HPI中断丢失
- 讲义8:分组查询