Android开发 VectorDrawable 矢量图 (四)矢量图动画放入到一个xml文件中

Android开发 VectorDrawable 矢量图 (四)矢量图动画放入到一个xml文件中,第1张

概述前言在前面的博客Android开发VectorDrawable矢量图(三)矢量图动画里,了解了group动画与path动画的实现。但是,可能有些人会觉得这些动画的实现的xml文件实在是太多了。此篇博客就将说明如何将所有的矢量图与动画全放到一个xml中。我们将还是用举例的方式说明。 颜色渐变gr 前言

  在前面的博客Android 开发 VectorDrawable 矢量图 (三)矢量图动画里,了解了group动画与path动画的实现。但是,可能有些人会觉得这些动画的实现的xml文件实在是太多了。此篇博客就将说明如何将所有的矢量图与动画全放到一个xml中。我们将还是用举例的方式说明。

 

颜色渐变group动画1.首先,老规矩找一个现成的矢量图,我们在AndroID studio自带的矢量图库里找一个矢量图

        

2.然后在drawable文件夹里,创建一个我们要放矢量图加动画组合的一个xml。并且先写入下面这些属性。

请注意!

xmlns:androID="http://schemas.androID.com/apk/res/androID"

xmlns:appt="http://schemas.androID.com/aapt"

这2个属性不是默认的,并且没有代码提示,需要你手动输入或者复制黏贴,取代默认的xmlns:androID 属性。 另外 appt:attr  这个属性也是没有代码提示的。

ic_color_anim.xml

<?xml version="1.0" enCoding="utf-8"?><animated-vector    xmlns:androID="http://schemas.androID.com/apk/res/androID"    xmlns:appt="http://schemas.androID.com/aapt">    <appt:attr name="androID:drawable">            </appt:attr></animated-vector>
3.然后,我们将矢量图的xml代码复制到<appt:attr > 属性里
<?xml version="1.0" enCoding="utf-8"?><animated-vector    xmlns:androID="http://schemas.androID.com/apk/res/androID"    xmlns:appt="http://schemas.androID.com/aapt">    <appt:attr name="androID:drawable">        <vector androID:height="24dp" androID:tint="#F44336"            androID:vIEwportHeight="24.0"            androID:vIEwportWIDth="24.0"            androID:wIDth="24dp"            xmlns:androID="http://schemas.androID.com/apk/res/androID">            <path                androID:fillcolor="#FF000000"                androID:pathData="                M12,2                C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2                z                M13,17                h-2v-2h2v2zM13,13h-2L11,7h2v6                z"/>        </vector>    </appt:attr></animated-vector>

 

 

 

 

 

 

 

 

 

 

 

 

End

总结

以上是内存溢出为你收集整理的Android开发 VectorDrawable 矢量图 (四)矢量图动画放入到一个xml文件中全部内容,希望文章能够帮你解决Android开发 VectorDrawable 矢量图 (四)矢量图动画放入到一个xml文件中所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1062921.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-26
下一篇 2022-05-26

发表评论

登录后才能评论

评论列表(0条)

保存