Android开发中Shape画图

  1. 形状控件Shape,渲染出来简单的图形和颜色比图片更加高效也更轻量
  2. <?xmlversion="1.0"encoding="utf-8"?>
  3. <shapexmlns:android="http://schemas.android.com/apk/res/android">
  4. <!-- 填充 -->
  5. <solid
  6. android:color="#B2B2B2"
  7. />
  8. <!-- 大小 -->
  9. <size
  10. android:width="200dp"
  11. android:height="50dp"
  12. />
  13. <!-- 渐变色 -->
  14. <gradient
  15. android:startColor="#DBDCDD"
  16. android:endColor="#B8B9BB"
  17. android:centerColor="#ADADAF"
  18. android:angle="270"
  19. />
  20. <!-- 描边 -->
  21. <stroke
  22. android:width="2dp"
  23. android:color="#3D4148"
  24. />
  25. <!-- 圆角 -->
  26. <corners
  27. android:radius="5dp"
  28. />
  29. <padding
  30. android:left="10dp"
  31. android:top="10dp"
  32. android:right="10dp"
  33. android:bottom="10dp"
  34. />
  35. </shape>
  36. <!--
  37. 1、 solid
  38. 描述:内部填充
  39. 属性 android:color 填充颜色
  40. 2、size
  41. 描述:size: 大小
  42. 属性:
  43. android:width 表示形状的宽度
  44. android:height 表示形状的高度
  45. 3、gradient
  46. 描述: 渐变色
  47. 属性:
  48. android:startColor 起始颜色
  49. android:endColor 结束颜色
  50. android:angle 渐变角度(PS:当angle=0时,渐变色是从左向右。 然后逆时针方向转,当angle=90时为从下往上。angle必须为45的整数倍)
  51. android:type 渐变类型(取值:linear、radial、sweep)
  52. linear 线性渐变,这是默认设置
  53. radial 放射性渐变,以开始色为中心。
  54. sweep 扫描线式的渐变。
  55. android:centerColor 渐变中间颜色,即开始颜色与结束颜色之间的颜色
  56. android:useLevel 如果要使用LevelListDrawable对象,就要设置为true。设置为true无渐变。false有渐变色
  57. android:gradientRadius 渐变色半径.当android:type="radial" 时才使用。单独使用 android:type="radial"会报错。
  58. android:centerX 渐变中心X点坐标的相对位置
  59. android:centerY 渐变中心Y点坐标的相对位置
  60. 4、stroke
  61. 描述: stroke:描边 相当于html中的盒子模型的border
  62. 属性:
  63. android:width 描边的宽度
  64. android:color 描边的颜色
  65. android:dashWidth 表示描边的样式是虚线的宽度,
  66. 值为0时,表示为实线。值大于0则为虚线。
  67. android:dashGap 表示描边为虚线时,虚线之间的间隔 即“ - - - - ”
  68. 5、corners
  69. 描述: corners: 圆角
  70. 属性:
  71. android:radius 半径
  72. android:topLeftRadius 左上角半径
  73. android:topRightRadius 右上角半径
  74. 注意一下两个属性比较不同:
  75. android:bottomLeftRadius 右下角半径
  76. android:bottomRightRadius 左下角半径
  77. 6、padding
  78. 描述:内部边距,即内容与边的距离
  79. 属性:
  80. android:left 左内边距
  81. android:top 上内边距
  82. android:right 右内边距
  83. android:bottom 下内边距
  84. -->

本文出自 “Mr.Xu” 博客,请务必保留此出处http://xuzhiwei.blog.51cto.com/978424/972188

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值