转载:http://www.cnblogs.com/cyanfei/archive/2012/07/27/2612023.html

android shape的使用

shape用于设定形状,可以在selector,layout等里面使用,有6个子标签,各属性如下:

复制代码
<?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>
复制代码

填充:设置填充的颜色

间隔:设置四个方向上的间隔

大小:设置大小

圆角:同时设置五个属性,则Radius属性无效

android:Radius="20dp" 设置四个角的半径

android:topLeftRadius="20dp" 设置左上角的半径
android:topRightRadius="20dp" 设置右上角的半径
android:bottomLeftRadius="20dp" 设置右下角的半径
android:bottomRightRadius="20dp" 设置左下角的半径

描边:dashWidth和dashGap属性,只要其中一个设置为0dp,则边框为实现边框

android:width="20dp" 设置边边的宽度
android:color="@android:color/black" 设置边边的颜色
android:dashWidth="2dp" 设置虚线的宽度
android:dashGap="20dp" 设置虚线的间隔宽度

渐变:当设置填充颜色后,无渐变效果。angle的值必须是45的倍数(包括0),仅在type="linear"有效,不然会报错。android:useLevel 这个属性不知道有什么用。

angle对应值的起点如图:

更多相关文章

  1. android xml之动画篇 alpha、scale、translate、rotate、set的属
  2. 【Android开发经验】android:windowSoftInputMode属性详解
  3. android:excludeFromRecents 属性需要注意的小地方
  4. Android属性动画—实现第三方登录的上拉展开,下拉隐藏
  5. Android xml application属性详解
  6. RelativeLayout部分属性介绍
  7. android中自定义控件的属性

随机推荐

  1. 获取 MySQL innodb B+tree 的高度的方法
  2. MySQL之范式的使用详解
  3. linux使用mysqldump+expect+crontab实现m
  4. SQL 列不同的表查询结果合并操作
  5. MySQL5.7.31 64位免安装版使用教程图解
  6. 在SQL中对同一个字段不同值,进行数据统计
  7. 在sql中对两列数据进行运算作为新的列操
  8. 详解监听MySQL的binlog日志工具分析:Canal
  9. 简单了解SQL常用删除语句原理区别
  10. MySQL死锁检查处理的正常方法