Android Shape属性

<?xml version="1.0" encoding="utf-8"?>  
<shape xmlns:android="http://schemas.android.com/apk/res/android"  
android:shape="rectangle">  
<!-- rectangle:矩形、圆角矩形、弧形等  
    oval:圆、椭圆  
    line:线、实线、虚线  
    ring:环形 -->  

<corners  <!-- 圆角 只适用于rectangle类型-->  
    android:radius="integer"    <!-- 圆角半径 -->  
    android:bottomLeftRadius="integer"  
    android:bottomRightRadius="integer"  
    android:topLeftRadius="integer"  
    android:topRightRadius="integer" />  

<gradient  <!-- 渐变色 -->  
    <!-- 渐变的角度,线性渐变时才有效,必须是45的倍数 -->  
    android:angle="integer"  
    <!-- 渐变中心的相对X、Y坐标,放射渐变时才有效 -->  
    android:centerX="integer"  
    android:centerY="integer"  
    <!-- 渐变的半径,放射渐变(radial)时才有效-->  
    android:gradientRadius="integer"  
    <!-- 渐变开始、中心、结束的颜色 -->  
    android:startColor="color"  
    android:centerColor="integer"  
    android:endColor="color"  
    <!-- 渐变的类型 linear线性、radial放射、sweep扫描-->  
    android:type=["linear" | "radial" | "sweep"]  
    <!--  是否可在LevelListDrawable中使用 -->  
    android:useLevel=["true" | "false"] />  

<padding  <!-- 设置内容与形状边界的内间距 -->  
    android:left="integer"  
    android:top="integer"  
    android:right="integer"  
    android:bottom="integer" />  

<size  <!-- 大小 -->  
    android:width="integer"  
    android:height="integer" />  

<solid  <!-- 填充的颜色 -->  
    android:color="color" />  

<stroke  <!-- 刻画边线 -->  
    android:width="integer"  
    android:color="color"  
    android:dashWidth="integer"   <!-- 虚线长度 -->  
    android:dashGap="integer" />  <!-- 虚线间隔 -->  
</shape>

另本人做了一个demo


QQ图片20180423143508.jpg
QQ图片20180423143520.jpg
QQ图片20180423143528.jpg
QQ图片20180423143534.jpg
QQ图片20180423143539.jpg

附上github地址:https://github.com/782520050/ShapeDemo.git

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • afinalAfinal是一个android的ioc,orm框架 https://github.com/yangf...
    passiontim阅读 15,569评论 2 45
  • ANDROID样式的开发:SHAPE篇 转载自Keegan小钢并标明原文链接:http://keeganlee.m...
    一点墨汁阅读 838评论 0 1
  • 原创文章,转载请注明:转载自Keegan小钢 并标明原文链接:http://keeganlee.me/post/a...
    于加泽阅读 1,665评论 0 5
  • 记得刚开始学Android时,看着自己完全用系统控件写出的不忍直视的界面,对于如何做出不一样的按钮,让它们在不同状...
    biloba阅读 1,747评论 1 11
  • 小时候,妈妈包饺子的时候,为了不让我捣乱,拿一块面团让我自己玩。我会把它弄成各种各样的造型,做一朵小花,捏个小金鱼...
    丹伦的笔记阅读 501评论 4 7