Lottie 以及可动画矢量图

1. 使用系统自带矢量图动画

  1.1 Android 系统自带矢量绘图动画 AnimatedVectorDrawable,官网Api地址

AnimatedVectorDrawableicon-default.png?t=M85Bhttps://developer.android.google.cn/reference/android/graphics/drawable/AnimatedVectorDrawable

  1.2 需要 .svg 格式文件,绘图软件绘制导出,或者下载.svg 文件

  1.3 Android studio 导入 .svg 文件,得到矢量图文件,例如 ic_my_vector.xml

  <vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="24dp"
    android:height="24dp"
    android:viewportWidth="240"
    android:viewportHeight="240">
    <path
        android:fillColor="#00000000"
        android:pathData="M66.28,60.75L170.22,60.75A8.03,8.03 0,0 1,178.25 68.78L178.25,172.22A8.03,8.03 0,0 1,170.22 180.25L66.28,180.25A8.03,8.03 0,0 1,58.25 172.22L58.25,68.78A8.03,8.03 0,0 1,66.28 60.75z"
        android:strokeWidth="7"
        android:strokeColor="#ed1e79" />
    <path
        android:fillColor="#00ff00"
        android:pathData="M125.41,96l98.4,66.51 -90,52L125.41,96m-3.61,-10.1A3.84,3.84 0,0 0,118 90l9.21,130a3.85,3.85 0,0 0,5.75 3.05l98.76,-57a3.84,3.84 0,0 0,0.23 -6.5l-108,-73a3.78,3.78 0,0 0,-2.14 -0.66Z" />
    <path
        android:fillColor="#0000ff"
        android:pathData="M89,102a50,50 0,1 1,-50 50,50.06 50.06,0 0,1 50,-50m0,-7a57,57 0,1 0,57 57A57,57 0,0 0,89 95Z" />
</vector>

  1.4 根据官方文档,创建动画文件 my_animated_vector.xml,供布局文件调用

<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:aapt="http://schemas.android.com/aapt">
    <aapt:attr name="android:drawable">
        <vector
            android:width="24dp"
           
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Hanyang Li

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值