搜索
热搜: 活动 交友 discuz
查看: 3079|回复: 0
打印 上一主题 下一主题

Android中Shape的属性说明及其使用

[复制链接]

160

主题

165

帖子

814

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
814
跳转到指定楼层
楼主
发表于 2018-9-17 09:04:13 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <shape xmlns:android="http://schemas.android.com/apk/res/android"
  3.     android:dither="false|true"             //将在位图的像素配置与屏幕不同时(例如:ARGB 8888 位图和 RGB 565 屏幕)启用位图的抖动;值为“false”时则停用抖动。默认值为 true。
  4.     android:shape="rectangle|line|oval|ring"//分别为矩形、线、椭圆、环。默认为矩形rectangle
  5.     android:innerRadius="integer"           // shape为ring时可用,内环半径
  6.     android:innerRadiusRatio="float"        // shape为ring时可用,内环的厚度比,即环的宽度比表示内环半径,默认为3,可被innerRadius值覆盖
  7.     android:thickness="integer"             // shape为ring时可用,环的厚度
  8.     android:thicknessRatio="float"          // shape为ring时可用,环的厚度比,即环的宽度比表示环的厚度,默认为9,可被thickness值覆盖
  9.     android:tint="color"                    // 给shape着色
  10.     android:tintMode="src_in|src_atop|src_over|add|multiply|screen" // 着色类型
  11.     android:useLevel="false|true"           // 较少用,一般设为false,否则图形不显示。为true时可在LevelListDrawable使用
  12.     android:visible="false|true"
  13.     >
  14.     <!-- 圆角 -->
  15.     <corners
  16.         android:radius="integer"            // 圆角半径,该值设置时下面四个属性失效
  17.         android:bottomLeftRadius="integer"  // 左下角圆角半径
  18.         android:bottomRightRadius="integer" // 右下角圆角半径
  19.         android:topLeftRadius="integer"     // 左上角圆角半径
  20.         android:topRightRadius="integer"    // 右上角圆角半径
  21.         />
  22.     <!-- 渐变 -->
  23.     <gradient
  24.         android:useLevel="false|true"       // 与上面shape中该属性的一致
  25.         android:type="linear|radial|sweep"  // 渐变类型,分别为线性、放射性、扫描性渐变,默认为线性渐变linear
  26.         android:angle="integer"             // 渐变角度,当上面type为线性渐变linear时有效。角度为45的倍数,0度时从左往右渐变,角度方向逆时针
  27.         android:centerColor="color"         // 渐变中间位置颜色
  28.         android:startColor="color"          // 渐变开始位置颜色
  29.         android:endColor="color"            // 渐变结束位置颜色
  30.         android:centerX="float"             // type为放射性渐变radial时有效,设置渐变中心的X坐标,取值区间[0,1],默认为0.5,即中心位置
  31.         android:centerY="float"             // type为放射性渐变radial时有效,设置渐变中心的Y坐标,取值区间[0,1],默认为0.5,即中心位置
  32.         android:gradientRadius="integer"    // type为放射性渐变radial时有效,渐变的半径
  33.         />
  34.     <!-- 内边距 -->
  35.     <padding
  36.         android:bottom="integer"  // 设置底部边距
  37.         android:left="integer"    // 左边边距
  38.         android:right="integer"   // 右边
  39.         android:top="integer"     // 顶部
  40.     />
  41.     <!-- 大小 -->
  42.     <size
  43.         android:height="integer"  // 宽度
  44.         android:width="integer"   // 高度
  45.         />
  46.     <!-- 填充 -->
  47.     <solid
  48.         android:color="color"     // shape的填充色
  49.         />
  50.     <!-- 描边 -->
  51.     <stroke
  52.         android:color="color"       // 描边的颜色
  53.         android:width="integer"     // 描边的宽度
  54.         android:dashGap="integer"   // 虚线间隔
  55.         android:dashWidth="integer" // 虚线宽度
  56.     />
  57. </shape>
复制代码


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|安卓论坛  

GMT+8, 2024-5-15 21:47 , Processed in 0.057546 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2013 Design S!|ƽ̶

快速回复 返回顶部 返回列表