android:dataPath解析

位于res/drawable/face.xml
<vector
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:height="200dp"
    android:width="200dp"
    android:viewportHeight="100"
    android:viewportWidth="100" >
  <path
      android:strokeColor="@android:color/holo_red_dark"
      android:fillColor="@color/yellow"
      android:pathData="@string/path_circle"/>
  <path
      android:fillColor="@android:color/black"
      android:pathData="@string/path_face_left_eye"/>
  <path
      android:fillColor="@android:color/black"
      android:pathData="@string/path_face_right_eye"/>
  <path
      android:name="mouth"
      android:strokeColor="@android:color/black"
      android:strokeWidth="@integer/stroke_width"
      android:strokeLineCap="round"
      android:pathData="@string/path_face_mouth_sad"/>
</vector>

res/values/strings.xml


<string name="path_circle">
    M 50,50
    m -48,0
    a 48,48 0 1,0 96,0
    a 48,48 0 1,0 -96,0
  </string>
  <string name="path_face_left_eye">
    M 35,40
    m -7,0
    a 7,7 0 1,0 14,0
    a 7,7 0 1,0 -14,0
  </string>
  <string name="path_face_right_eye">
    M 65,40
    m -7,0
    a 7,7 0 1,0 14,0
    a 7,7 0 1,0 -14,0
  </string>
  <string name="path_face_mouth_sad">
    M 30,75
    Q 50,55 70,75
  </string>
  <string name="path_face_mouth_happy">
    M 30,65
    Q 50,85 70,65
  </string>

参考文章:
http://www.w3.org/TR/SVG/paths.html#PathData

M是移动的意思,大写代表绝对坐标,小写是相对坐标,注意相对的对象是其前一个对象。
a是画弧,48,48分别是所画弧的x,y轴的半径,0是x轴偏移量,1是取大弧,0是逆时针,(96,0)是终点坐标。  
下面的a同理。  <span style="font-family: Arial, Helvetica, sans-serif;">若将48全换成24,96全换成48,会看到圆的半径为原来的一半。 </span><span style="font-family: Arial, Helvetica, sans-serif;"> </span>

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值