nqkk58 发表于 2024-10-3 11:12:19

Android SVG运用之AnimatedVectorDrawable


    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="http://mmbiz.qpic.cn/mmbiz_png/v1LbPPWiaSt4hS75rECCEiakbrpaQcLmuFMQhAqetW9hFoAGY8RJdgwr464AunYSbvEH1ic9fIZ8LzugaFaQhj7mQ/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;"></p><span style="color: black;">今日科技快讯</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">近期</span>有统计<span style="color: black;">公司</span>在北京<span style="color: black;">颁布</span>:2016届中国大学毕业生在毕业半年后的就业率为91.6%,这些毕业生平均月收入达到3988元。本科专业中,列在“高薪榜”前五位的专业分别是信息安全(5906元),软件工程(5869元),网络工程(5600元),微电子学(5503元)和计算机科学与技术(5452元)。</span></p><span style="color: black;">作者简介</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">本篇来自 <strong style="color: blue;">Nemo </strong>的投稿,<span style="color: black;">仔细</span>地介绍了SVG的属性以及<span style="color: black;">运用</span>方式,感兴趣的<span style="color: black;">伴侣</span><span style="color: black;">能够</span>自己试一试。<span style="color: black;">另一</span>点击最后 <span style="color: black;"><strong style="color: blue;">阅读原文&nbsp;</strong></span>可查看<span style="color: black;">有些</span>SVG<span style="color: black;">关联</span>资料的链接。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">Nemo</span></strong><span style="color: black;"> 的博客<span style="color: black;">位置</span>:</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">http://blog.csdn.net/nemo__</span></p><span style="color: black;">概述</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">SVG</span></strong><span style="color: black;"> 即 <strong style="color: blue;">可缩放矢量图形</strong>(Scalable Vector Graphics),是<span style="color: black;">运用</span>XML来描述二维图形和绘图程序的语言,其定义遵循W3C标准。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">在2003年1月,SVG 1.1被确立为W3C标准。<span style="color: black;">运用</span> SVG 的<span style="color: black;">优良</span>在于:</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">SVG 可被非常多的工具读取和修改(<span style="color: black;">例如</span>记事本)</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">SVG 与 JPEG 和 GIF 图像比起来,尺寸更小,且可压缩性更强</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">SVG 是可伸缩的</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">SVG 图像可在任何的分辨率下被高质量地打印</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">SVG 可在图像质量不下降的<span style="color: black;">状况</span>下被放大</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">SVG 图像中的文本是可选的,<span style="color: black;">同期</span><span style="color: black;">亦</span>是可搜索的(很适合制作地图)</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">SVG <span style="color: black;">能够</span>与 Java 技术<span style="color: black;">一块</span>运行</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">SVG 是开放的标准</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">SVG 文件是纯粹的 XML</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">下面的例子是一个简单的SVG文件的例子。SVG文件必须<span style="color: black;">运用</span>.svg后缀来<span style="color: black;">保留</span>:</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="http://mmbiz.qpic.cn/mmbiz_png/v1LbPPWiaSt5bNjzOCiaO4HZpKiaKicKTG3yvib2uQQUQYG7uGbo2aCib5We9LpfFicDdc8InnAj4oNiap8TIEagxRiau3A/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;"></p><span style="color: black;">HTML页面中<span style="color: black;">运用</span>SVG</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">SVG 文件可<span style="color: black;">经过</span>以下标签嵌入 HTML 文档:<strong style="color: blue;">&lt;embed&gt;</strong>、<strong style="color: blue;">&lt;object&gt;</strong>&nbsp;<span style="color: black;">或</span>&nbsp;<strong style="color: blue;">&lt;iframe&gt;</strong>。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;"><span style="color: black;">运用</span>&lt;embed&gt;标签</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">&lt;embed&gt; 标签被所有主流的浏览器支持,并<span style="color: black;">准许</span><span style="color: black;">运用</span>脚本。当在 HTML 页面中嵌入 SVG 时<span style="color: black;">运用</span>&nbsp;&lt;embed&gt;&nbsp;标签是 Adobe SVG Viewer <span style="color: black;">举荐</span>的<span style="color: black;">办法</span>!然而,<span style="color: black;">倘若</span>需要创建合法的 XHTML,就<span style="color: black;">不可</span><span style="color: black;">运用</span>&nbsp;&lt;embed&gt;。任何 HTML 规范中都<span style="color: black;">无</span>&nbsp;&lt;embed&gt;&nbsp;标签。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="http://mmbiz.qpic.cn/mmbiz_png/v1LbPPWiaSt5bNjzOCiaO4HZpKiaKicKTG3yhEyLY7lKqWHIlcuWIf5whtaxicojGwxMVBia6QJYbzvxic858bP7piaiaHg/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;"></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;"><span style="color: black;">运用</span>&lt;object&gt;标签</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">&lt;object&gt;标签是HTML 4的标准标签,被所有较新的浏览器支持。它的缺点是不<span style="color: black;">准许</span><span style="color: black;">运用</span>脚本。假如您安装了最新版本的Adobe SVG Viewer,<span style="color: black;">那样</span>当<span style="color: black;">运用</span>&lt;object&gt;标签时SVG文件<span style="color: black;">没法</span>工作(<span style="color: black;">最少</span><span style="color: black;">不可</span>在 IE 中工作)!</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="http://mmbiz.qpic.cn/mmbiz_png/v1LbPPWiaSt5bNjzOCiaO4HZpKiaKicKTG3yFngDq49b5RdBcHzXBAFHGEO3xmROJ7bErFDPUibIP4Xhzh8yvU3iaRUQ/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;"></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;"><span style="color: black;">运用</span>&lt;iframe&gt;标签</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">&lt;iframe&gt;标签可工作在大部分的浏览器中。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="http://mmbiz.qpic.cn/mmbiz_png/v1LbPPWiaSt5bNjzOCiaO4HZpKiaKicKTG3yuGbB51xZAAoQ78a25y4eaibA3o5pUYBT2xFNAoyV7bS720LHWHibibIqw/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;"></p><span style="color: black;">SVG&lt;path&gt;</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">SVG的&lt;path&gt;元素用于定义<span style="color: black;">有些</span><span style="color: black;">繁杂</span>的图形,其定义在</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">W3 SVG Path</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">https://www.w3.org/TR/SVG11/paths.html#PathData</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">&lt;path&gt;可用的命令如下:</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="http://mmbiz.qpic.cn/mmbiz_png/v1LbPPWiaSt5bNjzOCiaO4HZpKiaKicKTG3ybicaZTDzicGXNm5ILs83yjh17j7dZiazgWJeZudnlQpIXOVjOLousjgTQ/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;"></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">以上所有命令均<span style="color: black;">准许</span>小写字母。<strong style="color: blue;">大写的字母</strong>是基于原点的坐标系(偏移量),即绝对位置;<strong style="color: blue;">小写字母</strong>是基于当前点坐标系(偏移量),即相对位置。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">所有绘制工作都是在&lt;path&gt;元素中<span style="color: black;">经过</span> d属性 来完成的。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="http://mmbiz.qpic.cn/mmbiz_png/v1LbPPWiaSt5bNjzOCiaO4HZpKiaKicKTG3yy7OQIO7lmdfRognxfEBYnpCA26MU8kqcWGnPzMPYx1Cy34ccDiaQj8g/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;"></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">(1) </span></strong><span style="color: black;">坐标轴为以(0,0)为中心,X轴水平向右,Y轴水平向下</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">(2) </span></strong><span style="color: black;">命令与参数间的空格<span style="color: black;">能够</span>省略</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">M 250 150&nbsp;M250 150</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">(3) </span></strong><span style="color: black;">参数间<span style="color: black;">能够</span><span style="color: black;">运用</span>空格或逗号隔开</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">M 250,150&nbsp;M250,150</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">(4)</span></strong><span style="color: black;"> 同一指令<span style="color: black;">显现</span>多次<span style="color: black;">能够</span>只用一个</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">M300,70 l 0,-70 70,70 0,0 -70,70z</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">(5) </span></strong><span style="color: black;">命令大写字母基于坐标系原点,小写字母基于当前位置</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">假如虚拟画笔<span style="color: black;">起始</span>绘制的位置是(50,50),<span style="color: black;">倘若</span><span style="color: black;">运用</span>的是L100,100指令,<span style="color: black;">那样</span><span style="color: black;">便是</span>从(50,50)位置<span style="color: black;">起始</span>绘制直线,绘制到(100,100)的位置。<span style="color: black;">倘若</span>是l100,100指令,<span style="color: black;">那样</span>直线将从(50,50)位置<span style="color: black;">起始</span>绘制,绘制到(50+100,50+100)的位置。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">(6) </span></strong><span style="color: black;">闭合路径<span style="color: black;">指的是</span>从最后一个绘制点连线到<span style="color: black;">起始</span>点,这个命令是Z(或z,<span style="color: black;">这儿</span><span style="color: black;">体积</span>写<span style="color: black;">无</span>区别)</span></p><span style="color: black;"><strong style="color: blue;">SVG Stroke属性</strong></span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">SVG<span style="color: black;">供给</span>了一个范围广泛stroke 属性。在本章中,<span style="color: black;">咱们</span>将<span style="color: black;">瞧瞧</span>下面:</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">stroke&nbsp;</span></strong><span style="color: black;">定义一条线,文本或元素轮廓颜色</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">stroke-width</span></strong><span style="color: black;">&nbsp;定义了一条线,文本或元素轮廓厚度</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">stroke-linecap</span></strong><span style="color: black;">定义<span style="color: black;">区别</span>类型的开放路径的终结,对接(butt)、圆形(round)和方形(square);</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">stroke-linejoin</span></strong><span style="color: black;">&nbsp;<span style="color: black;">掌控</span>两条线段之间的衔接,三个值:尖角(miter)、圆角(round)和斜角(bevel);</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">stroke-miterlimit</span></strong><span style="color: black;">miter-length 和 stroke-width 之间的比率做了限制,它的比值范围应大于或等于1。当比值不在这个范围的时候, stroke 就会被转换成斜角(bevel)。当 strokeLineJoin 设置为 “miter” 的时候,绘制两条线段以锐角相交的时候,所得的斜面可能相当长。当斜面太长,就会变得不协调。strokeMiterLimit属性为斜面的长度设置一个上限。这个属性<span style="color: black;">暗示</span>斜面长度和线条长度的比值。默认是10,<span style="color: black;">寓意</span>着一个斜面的长度<span style="color: black;">不该</span>该超过线条宽度的10倍。<span style="color: black;">倘若</span>斜面达到这个长度,它就变成斜角了。当strokeLineJoin为“round”或“bevel”的时候,这个属性无效。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">stroke-dasharray&nbsp;</span></strong><span style="color: black;">创建虚线</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">stroke-dashoffset</span></strong><span style="color: black;">设置需要图案延迟绘制的距离</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">stroke-opacity</span></strong><span style="color: black;">&nbsp;线条,文本或元素轮廓透明度;</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">可能的取值如下:</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="http://mmbiz.qpic.cn/mmbiz_png/v1LbPPWiaSt5bNjzOCiaO4HZpKiaKicKTG3yIe1jiaTDAlTTsicywL9iaJmSVQAJg8z63crCDwwCrQXKgdWmGeG9buGUA/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;"></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">以下为 stroke属性 的范例 stroke.avg,<span style="color: black;">能够</span>较好地理解各项含义:</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="http://mmbiz.qpic.cn/mmbiz_png/v1LbPPWiaSt5bNjzOCiaO4HZpKiaKicKTG3yPMCEe6eUS93gicL0iciaX76QuZPklvzwerm9MibPWXGcnaGOLw8j1mTtqA/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;"></p><span style="color: black;"><strong style="color: blue;">&lt;path&gt;标签A指令</strong></span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">&lt;path&gt;标签 d属性 中,A指令 可用于画一段椭圆孤。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">A指令格式</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">elliptical Arc (A RX,RY,XROTATION,large-arc-flag,sweep-flag,X,Y)</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">RX,RY</span></strong><span style="color: black;"> &nbsp;所在椭圆水平方向上的半径,垂直方向上的半径;RX 和 RY 设置为相同的值,将得到一个圆形的弧线 &nbsp;</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">XROTATION</span></strong><span style="color: black;">椭圆的X轴与水平方向顺时针方向夹角,<span style="color: black;">能够</span>想像成一个水平的椭圆绕中心点顺时针旋转XROTATION的<span style="color: black;">方向</span>。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">large-arc-flag,1<span style="color: black;">暗示</span>大<span style="color: black;">方向</span>弧线,0为小<span style="color: black;">方向</span>弧线。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">sweep-flag</span></strong><span style="color: black;">,确定从起点至终点的方向,1为顺时针,0为逆时针</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">X,Y </span></strong><span style="color: black;">为终点坐标 &nbsp;</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">A指令图形详解,<span style="color: black;">能够</span>把arc.svg<span style="color: black;">保留</span>到本地,在浏览器中查看:</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="http://mmbiz.qpic.cn/mmbiz_png/v1LbPPWiaSt5bNjzOCiaO4HZpKiaKicKTG3yZmNV9njGwofbWSniaGW4R3PGS3fRiccF3BicNkeq8SiaMPSonELDiaENCQw/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;"></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">效果如下:</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="http://mmbiz.qpic.cn/mmbiz_png/v1LbPPWiaSt5bNjzOCiaO4HZpKiaKicKTG3yDsiaQgjAjDvomJfV8d758mgZkIl8U3KSic3edCnKyib4gOfm9wBxhjUOQ/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;"></p><strong style="color: blue;"><span style="color: black;">&lt;path&gt;标签画贝塞尔曲线</span></strong>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">&lt;path&gt;标签d属性中,绘制贝塞尔曲线的命令<span style="color: black;">包含</span>:</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">Q </span></strong><span style="color: black;">二次贝赛尔曲线 x1,y1 x,y</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">T</span></strong><span style="color: black;"> 平滑二次贝塞尔曲线 x,y</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">C </span></strong><span style="color: black;">曲线(curveto) x1,y1 x2,y2 x,y</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">S</span></strong><span style="color: black;"> 平滑曲线 x2,y2 x,y</span></p><strong style="color: blue;"><span style="color: black;">(1) Q 二次贝塞尔曲线</span></strong>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">Q指令格式:M x0,y0 Q x1,y1 x2,y2</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">经过</span>M定义(x0,y0)为起点,用Q定义(x1,y1)为<span style="color: black;">掌控</span>点,(x2,y2)为终点,<span style="color: black;">形成</span>一条二次贝塞尔曲线。 Q<span style="color: black;">办法</span>非常简单直观。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="http://mmbiz.qpic.cn/mmbiz_png/v1LbPPWiaSt5bNjzOCiaO4HZpKiaKicKTG3ykrFo2BqklQygpjsmeBF4uktTaPsJWEc2Y6v8KlF9M2u606ic9VMjUTA/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;"></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">效果如下:</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="http://mmbiz.qpic.cn/mmbiz_png/v1LbPPWiaSt5bNjzOCiaO4HZpKiaKicKTG3y8ZAM7iaVKcCz65m92KYSmKGKcCBL5rCFHE90rboDPf4fHbaT5E9PPzA/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;"></p><strong style="color: blue;"><span style="color: black;">(2) T 二次贝塞尔曲线平滑延伸</span></strong>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">T指令格式:M x0,y0 Q x1,y1 x2,y2 T x4,y4</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">T命令是二次被赛尔曲线的平滑延伸命令,用Q定义了一段二次贝塞尔曲线后面,紧接着一个T命令,只需定义终点,就<span style="color: black;">能够</span>自动延伸出一条平滑的曲线。在这段曲线中,(x3,y3)<span style="color: black;">无</span>手工定义,<span style="color: black;">这儿</span><span style="color: black;">运用</span>的T<span style="color: black;">办法</span>,只定义一个终点,起点是上一段曲线的终点,<span style="color: black;">掌控</span>点则是上一段曲线的<span style="color: black;">掌控</span>点的对<span style="color: black;">叫作</span>点(相<span style="color: black;">针对</span>上一段曲线的终点)。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">T命令前面必须是一个Q命令,<span style="color: black;">或</span>是另一个T命令,<span style="color: black;">才可</span>达到这种效果。<span style="color: black;">倘若</span>T单独<span style="color: black;">运用</span>,<span style="color: black;">那样</span><span style="color: black;">掌控</span>点就会被认为和终点是同一个点,<span style="color: black;">因此</span>画出来的将是一条直线。</span></strong></p><strong style="color: blue;"><span style="color: black;">(3) C 三次贝塞尔曲线</span></strong>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">C指令格式:M x0,y0 C x1,y1 x2,y2 x3,y3</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">C<span style="color: black;">办法</span>定义的是三次贝塞尔曲线,只是多了一个<span style="color: black;">掌控</span>点。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="http://mmbiz.qpic.cn/mmbiz_png/v1LbPPWiaSt5bNjzOCiaO4HZpKiaKicKTG3yJAQAAUSlpGY6CnUaeXqoz8GKUQc4BpBbPE8acBia5bu1aF6mHwZhPMw/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;"></p><strong style="color: blue;"><span style="color: black;">(4) S 三次贝塞尔曲线平滑延伸</span></strong>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">S指令格式:M x0,y0 C x1,y1 x2,y2 x3,y3 S x5,y5 x6,y6</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">三次贝塞尔<span style="color: black;">亦</span>有一个平滑延伸的命令,需要定义一个<span style="color: black;">掌控</span>点和一个终点,命令会再自动生成一个<span style="color: black;">掌控</span>点x4,y4,从而形成一条延伸出来的三次贝赛尔曲线。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">S命令前面必须是一个C命令,<span style="color: black;">或</span>是另一个S命令,<span style="color: black;">才可</span>达到这种效果。<span style="color: black;">倘若</span>单独<span style="color: black;">运用</span>S命令,则会变成画二次贝塞尔曲线效果。&nbsp;</span></p><span style="color: black;">Android SVG动画</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">AnimatedVectorDrawable类 <span style="color: black;">运用</span> ObjectAnimator 和 AnimatorSet 来<span style="color: black;">促进</span> VectorDrawable 属性渐变,来生成动画效果。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">一般</span><span style="color: black;">能够</span>在3个XML文件中定义添加动画的矢量<span style="color: black;">照片</span>:</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">在res/drawable/中<span style="color: black;">持有</span>元素的矢量<span style="color: black;">照片</span>;</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">在res/drawable/中<span style="color: black;">持有</span>元素且已添加动画的矢量<span style="color: black;">照片</span>;</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">在res/anim/中<span style="color: black;">持有</span>元素的一个或多个对象动画;</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">添加动画的矢量<span style="color: black;">照片</span>可为&lt;group&gt;以及&lt;path&gt;元素的属性添加动画。&lt;group&gt;元素定义路径集或子组,而&lt;path&gt;元素则定义将绘制的路径。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">完成一个 AnimatedVectorDrawable <span style="color: black;">一般</span>需要定义三种<span style="color: black;">区别</span>类型文件:</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">(1). </span></strong><span style="color: black;">android.graphics.drawable.VectorDrawable 对应的XML文件,它以&lt;vector&gt;为根。<span style="color: black;">咱们</span>可能让 path 或 group 的属性进行动画,<span style="color: black;">因此呢</span>需要对进行动画的 path 或 group 命名。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="http://mmbiz.qpic.cn/mmbiz_png/v1LbPPWiaSt5bNjzOCiaO4HZpKiaKicKTG3yHxJRyuOsRicAiagfWE5tia0aOBvaI2qgicC9Hv5tGCVuj0aQbIndJv1UZw/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;"></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">(2).</span></strong><span style="color: black;">android.graphics.drawable.AnimatedVectorDrawable 对应的XML文件,它以&lt;animated-vector&gt;为根。<span style="color: black;">这儿</span>定义需动画的 path 或 group 的&lt;target&gt;,&lt;target&gt;的animation属性指定为<span style="color: black;">通常</span>的 ObjectAnimator 或 AnimatorSet 对应的XML。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="http://mmbiz.qpic.cn/mmbiz_png/v1LbPPWiaSt5bNjzOCiaO4HZpKiaKicKTG3yuibpzElMq421LAReRIsokfwZaYqOFEiblPPIpt6crZ3WSVlLBS5NGNqg/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;"></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">(3).&nbsp;</span></strong><span style="color: black;">android.graphics.drawable.Animator对应的XML文件,它以&lt;set&gt;,&lt;objectAnimator&gt;等为根,对应 AnimatorSet 和 ObjectAnimator。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="http://mmbiz.qpic.cn/mmbiz_png/v1LbPPWiaSt5bNjzOCiaO4HZpKiaKicKTG3yDRofItDgnOGtxjcdjicvy5l4agry2kzo2wqYWGJ4JA54EqVO9uXZmwA/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;"></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="http://mmbiz.qpic.cn/mmbiz_png/v1LbPPWiaSt5bNjzOCiaO4HZpKiaKicKTG3ySw9ljucmD3X5lDCUuSkagAwxLnjUQM3PII1lP0xDTbLuRz2aR71SYQ/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;"></p><span style="color: black;"><strong style="color: blue;">VectorDrawable</strong></span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">VectorDrawable<span style="color: black;">通常</span>是以&lt;vector&gt;为根标签定义的XML文件,&lt;vector&gt;、&lt;group&gt;、&lt;clip-path&gt;、&lt;path&gt;元素都有各自<span style="color: black;">能够</span>播放动画的属性,查阅 SDK/docs/reference/android/graphics/drawable/VectorDrawable.html 你会找到每种元素到底有<span style="color: black;">哪些</span>属性,以便针对这些属性播放特定的动画。<span style="color: black;">例如</span> trimPathStart 和 trimPathEnd 能够让已画的path以百分比的形式渐变<span style="color: black;">显现</span>。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">&lt;vector&gt;定义这个矢量图</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">android:name 矢量图的名字</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">android:width 矢量图的内部(intrinsic)宽度,支持所有Android系统支持的尺寸,<span style="color: black;">一般</span><span style="color: black;">运用</span>dp</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">android:height 矢量图的内部(intrinsic)高度</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">android:viewportWidth 矢量图视图的宽度,视图<span style="color: black;">便是</span>矢量图path路径数据所绘制的虚拟画布</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">android:viewportHeight 矢量图视图的高度</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">android:tint 矢量图的tint颜色。默认是<span style="color: black;">无</span>tint颜色的</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">android:tintMode 矢量图tint颜色的Porter-Duff混合模式,默认值为src_in。(src_in,src_over,src_atop,add,screen,multiply)</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">android:autoMirrored 设置当系统为RTL(right-to-left)布局的时候,<span style="color: black;">是不是</span>自动镜像该<span style="color: black;">照片</span>。<span style="color: black;">例如</span>阿拉伯语。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">android:alpha 该<span style="color: black;">照片</span>的透明度属性</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">&lt;group&gt;设置路径做动画的关键属性的</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">android:name 定义group的名字</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">android:rotation 定义该group的路径旋转多少度</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">android:pivotX 定义缩放和旋转该group时候的X参考点。该值相<span style="color: black;">针对</span>vector的viewport值来指定的。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">android:pivotY 定义缩放和旋转该 group 时候的Y参考点。该值相<span style="color: black;">针对</span>vector的viewport值来指定的。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">android:scaleX 定义X轴的缩放倍数</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">android:scaleY 定义Y轴的缩放倍数</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">android:translateX 定义移动X轴的位移。相<span style="color: black;">针对</span>vector的viewport值来指定的。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">android:translateY 定义移动Y轴的位移。相<span style="color: black;">针对</span>vector的viewport值来指定的。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">&lt;path&gt;</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">android:name 定义该path的名字,<span style="color: black;">这般</span>在其他<span style="color: black;">地区</span><span style="color: black;">能够</span><span style="color: black;">经过</span>名字来引用这个路径</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">android:pathData 和SVG中d元素<span style="color: black;">同样</span>的路径信息。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">android:fillColor 定义填充路径的颜色,<span style="color: black;">倘若</span><span style="color: black;">无</span>定义则不填充路径</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">android:strokeColor 定义<span style="color: black;">怎样</span>绘制路径边框,<span style="color: black;">倘若</span><span style="color: black;">无</span>定义则不<span style="color: black;">表示</span>边框 &nbsp; android:strokeWidth 定义路径边框的粗细尺寸</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">android:strokeAlpha 定义路径边框的透明度</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">android:fillAlpha 定义填充路径颜色的透明度</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">android:trimPathStart 从路径<span style="color: black;">初始</span>位置截断路径的比率,取值范围从0到1;<span style="color: black;">重视</span>从一半到<span style="color: black;">初始</span>动画为from-0.5-to-0
            &nbsp; &nbsp;android:trimPathEnd &nbsp; &nbsp;从路径结束位置截断路径的比率,取值范围从0到1;<span style="color: black;">重视</span>从一半到结束动画为from-0.5-to-1.0</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">android:trimPathOffset 设置路径截取的范围,取值范围从0到1</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">android:strokeLineCap 设置路径线帽的形状,取值为 butt, round, square.</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">android:strokeLineJoin 设置路径交界处的连接方式,取值为 miter,round,bevel. android:strokeMiterLimit 设置斜角的上限</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">&lt;clip-path&gt; 定义当前绘制的剪切路径。<span style="color: black;">重视</span>,clip-path 只对当前的 group 和子 group 有效</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">android:name 定义clip-path的名字</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">android:pathData android:pathData的取值<span style="color: black;">同样</span>。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">根元素 &lt;vector&gt; 上有两个宽高设置,其中 viewport 是指矢量图里面的画布<span style="color: black;">体积</span>,而 android:width 和 android:height <span style="color: black;">指的是</span>该矢量图所对应的 VectorDrawable 的<span style="color: black;">体积</span>。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">关于tintMode:</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">在5.0以后<span style="color: black;">咱们</span>就<span style="color: black;">能够</span>为 bitmap <span style="color: black;">或</span>是 9-patch 定义一个透明的遮罩。BitmapDrawable 和 NinePatchDrawable <span style="color: black;">运用</span> setTint()<span style="color: black;">办法</span>。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">而在xml文件中<span style="color: black;">运用</span> android:tint 和 android:tintMode 这两个属性。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;"><span style="color: black;">重视</span>点:</span></strong><strong style="color: blue;"><span style="color: black;"><span style="color: black;">运用</span> android:tint 指定颜色时<span style="color: black;">必定</span>要带透明度。#50ff00ff<span style="color: black;">亦</span><span style="color: black;">便是</span>说是8位的色值而不是6位的。</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">属性说明:</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">android:tint: 设置的是颜色</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">android:tintMode:设置的是类型(src_in,src_over,src_atop,add,screen,multiply)</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">类型说明:</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">src_in 只<span style="color: black;">表示</span>设置的遮罩颜色。 相当于遮罩在里面。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">src_over 遮罩颜色和<span style="color: black;">照片</span>都<span style="color: black;">表示</span>。相当于遮罩在<span style="color: black;">照片</span>上方。(<span style="color: black;">尤其</span>是色值带透明度的)</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">src_atop 遮罩在<span style="color: black;">照片</span>上方
            multiply 混合色遮罩</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">screen add 混合遮罩,drawable颜色和透明度。</span></p><span style="color: black;"><strong style="color: blue;">AnimatedVectorDrawable</strong></span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">AnimatedVectorDrawable <span style="color: black;">经过</span> ObjectAnimator 或 AnimatorSet 对 VectorDrawable 的某个属性作动画。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">从API-25<span style="color: black;">起始</span>,AnimatedVectorDrawable 运行在 RenderThread(相反地,<span style="color: black;">初期</span>API是运行在UI线程)。这<span style="color: black;">亦</span><span style="color: black;">便是</span>说 AnimatedVectorDrawable 在UI线程繁忙时<span style="color: black;">亦</span>能保持流畅运行。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">倘若</span>UI线程<span style="color: black;">无</span>反应,RenderThread 会<span style="color: black;">连续</span>动画计算,直到UI线程有能力推进下一帧。<span style="color: black;">因此呢</span>,<span style="color: black;">无</span>办法准确地同步 RenderThread-enabled 的 AnimatedVectorDrawable 和UI线程中的 Animations。<span style="color: black;">另外</span>,Animatable2.AnimationCallback.onAnimationEnd(drawable)肯定会在 RenderThread 渲染完 AnimatedVectorDrawable 最后一帧时被调用。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">AnimatedVectorDrawable <span style="color: black;">能够</span>被定义在三个XML文件或一个XML中。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="data:image/svg+xml,%3C%3Fxml version=1.0 encoding=UTF-8%3F%3E%3Csvg width=1px height=1px viewBox=0 0 1 1 version=1.1 xmlns=http://www.w3.org/2000/svg xmlns:xlink=http://www.w3.org/1999/xlink%3E%3Ctitle%3E%3C/title%3E%3Cg stroke=none stroke-width=1 fill=none fill-rule=evenodd fill-opacity=0%3E%3Cg transform=translate(-249.000000, -126.000000) fill=%23FFFFFF%3E%3Crect x=249 y=126 width=1 height=1%3E%3C/rect%3E%3C/g%3E%3C/g%3E%3C/svg%3E" style="width: 50%; margin-bottom: 20px;"></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">重点</span><span style="color: black;">办法</span>:</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="data:image/svg+xml,%3C%3Fxml version=1.0 encoding=UTF-8%3F%3E%3Csvg width=1px height=1px viewBox=0 0 1 1 version=1.1 xmlns=http://www.w3.org/2000/svg xmlns:xlink=http://www.w3.org/1999/xlink%3E%3Ctitle%3E%3C/title%3E%3Cg stroke=none stroke-width=1 fill=none fill-rule=evenodd fill-opacity=0%3E%3Cg transform=translate(-249.000000, -126.000000) fill=%23FFFFFF%3E%3Crect x=249 y=126 width=1 height=1%3E%3C/rect%3E%3C/g%3E%3C/g%3E%3C/svg%3E" style="width: 50%; margin-bottom: 20px;"></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">代码中<span style="color: black;">运用</span>:</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="data:image/svg+xml,%3C%3Fxml version=1.0 encoding=UTF-8%3F%3E%3Csvg width=1px height=1px viewBox=0 0 1 1 version=1.1 xmlns=http://www.w3.org/2000/svg xmlns:xlink=http://www.w3.org/1999/xlink%3E%3Ctitle%3E%3C/title%3E%3Cg stroke=none stroke-width=1 fill=none fill-rule=evenodd fill-opacity=0%3E%3Cg transform=translate(-249.000000, -126.000000) fill=%23FFFFFF%3E%3Crect x=249 y=126 width=1 height=1%3E%3C/rect%3E%3C/g%3E%3C/g%3E%3C/svg%3E" style="width: 50%; margin-bottom: 20px;"></p><span style="color: black;"><span style="color: black;">更加多</span></span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">每日</span>学习累了,看些搞笑的段子放松一下吧。</span><span style="color: black;">关注最具娱乐精神的公众号,<span style="color: black;">每日</span>都有好心情。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="data:image/svg+xml,%3C%3Fxml version=1.0 encoding=UTF-8%3F%3E%3Csvg width=1px height=1px viewBox=0 0 1 1 version=1.1 xmlns=http://www.w3.org/2000/svg xmlns:xlink=http://www.w3.org/1999/xlink%3E%3Ctitle%3E%3C/title%3E%3Cg stroke=none stroke-width=1 fill=none fill-rule=evenodd fill-opacity=0%3E%3Cg transform=translate(-249.000000, -126.000000) fill=%23FFFFFF%3E%3Crect x=249 y=126 width=1 height=1%3E%3C/rect%3E%3C/g%3E%3C/g%3E%3C/svg%3E" style="width: 50%; margin-bottom: 20px;"></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">倘若</span>你有好的技术<span style="color: black;">文案</span>想和<span style="color: black;">大众</span>分享,欢迎向我的公众号投稿,投稿<span style="color: black;">详细</span>细节请在公众号主页点击</span><strong style="color: blue;">“投稿”</strong><span style="color: black;">菜单查看。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">欢迎<strong style="color: blue;">长按下图&nbsp;-&gt;&nbsp;识别图中二维码</strong><span style="color: black;">或</span><strong style="color: blue;">扫一扫</strong>关注我的公众号:</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="data:image/svg+xml,%3C%3Fxml version=1.0 encoding=UTF-8%3F%3E%3Csvg width=1px height=1px viewBox=0 0 1 1 version=1.1 xmlns=http://www.w3.org/2000/svg xmlns:xlink=http://www.w3.org/1999/xlink%3E%3Ctitle%3E%3C/title%3E%3Cg stroke=none stroke-width=1 fill=none fill-rule=evenodd fill-opacity=0%3E%3Cg transform=translate(-249.000000, -126.000000) fill=%23FFFFFF%3E%3Crect x=249 y=126 width=1 height=1%3E%3C/rect%3E%3C/g%3E%3C/g%3E%3C/svg%3E" style="width: 50%; margin-bottom: 20px;"></p>




j8typz 发表于 2024-10-19 17:15:43

楼主的文章非常有意义,提升了我的知识水平。

b1gc8v 发表于 前天 15:37

感谢您的精彩评论,为我带来了新的思考角度。

qzmjef 发表于 前天 23:09

谷歌外链发布 http://www.fok120.com/
页: [1]
查看完整版本: Android SVG运用之AnimatedVectorDrawable