Android SVG动画animated-vector使用
来源:互联网 发布:罗莱蚕丝被 知乎 编辑:程序博客网 时间:2024/05/29 11:56
Android5.0版本增加的SVG动画animated-vector,使用时sdk版本大于等于21
使用:第二个svg动画
1.在drawable/ic_svg2.xml
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="200dp" android:height="200dp" android:viewportHeight="100" android:viewportWidth="100"> <group> <path android:name="path1" android:fillColor="#0000" android:pathData="M20,80L80,80" android:strokeColor="@android:color/background_dark" android:strokeLineCap="round" android:strokeWidth="5" /> <path android:name="path2" android:fillColor="#0000" android:pathData="M20,20L80,20" android:strokeColor="@android:color/background_dark" android:strokeLineCap="round" android:strokeWidth="5" /> <path android:name="path3" android:fillColor="#0000" android:pathData="M20,50L80,50" android:strokeColor="@android:color/background_dark" android:strokeLineCap="round" android:strokeWidth="5" /> </group></vector>
2./animator/anim_path21.xml
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android" android:duration="500" android:propertyName="pathData" android:valueFrom="M20,80L80,80" android:valueTo="M50,80L80,50" android:valueType="pathType" />
3./animator/anim_path22.xml
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android" android:duration="500" android:propertyName="pathData" android:valueFrom="M20,20L80,20" android:valueTo="M50,20L80,50" android:valueType="pathType" />
4./drawable/anim_vector2.xml
<?xml version="1.0" encoding="utf-8"?><animated-vector xmlns:android="http://schemas.android.com/apk/res/android" android:drawable="@drawable/ic_svg2"> <target android:name="path1" android:animation="@animator/anim_path21" /> <target android:name="path2" android:animation="@animator/anim_path22" /></animated-vector>
5.在activity中使用
ImageView imageView2 = (ImageView) findViewById(R.id.image2); imageView2.setImageDrawable(getDrawable(R.drawable.anim_vector2)); imageView2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { final Drawable drawable = imageView.getDrawable(); if (drawable instanceof Animatable){ ((Animatable) drawable).start(); } } });
示例代码下载
阅读全文
0 0
- Android SVG动画animated-vector使用
- Android Material Design动画 Animated Vector Drawables|矢量图片动画
- Android 使用SVG动画
- 图标动画 Animated SVG Icons with Snap.svg
- Android使用SVG矢量动画(二)
- React-Native项目中使用动画-Animated
- Android SVG动画
- Android SVG动画
- android SVG矢量动画
- Android 加载SVG动画
- Android Vector Drawable | SVG 矢量图
- Android使用SVG实现今日头条下拉刷新动画
- SVG-Android开源库——关于动画的使用
- 【Android 进阶】SVG 的使用以及绘制动画
- Android中svg动画框架PathView的使用
- Android使用SVG矢量图打造酷炫动画效果
- Android中使用SVG实现炫酷动画效果
- Vector Drawable、Animated Vector Drawable
- 如何使用vue实现一个简易的购物车
- linux下利用openssl来实现证书的颁发(详细步骤)
- JDBC中Scrollable ResultSet(滚动结果集)(四)
- PAT basic 1068
- 算法题/层次遍历二叉树
- Android SVG动画animated-vector使用
- 位图的简单实现(bitMap)
- 多版本jdk/eclipse/tomcat的处理
- Hadoop Streaming 做大数据处理详解
- hdu 6170 Two strings
- Android -- 获取接口数据的三个方法
- [USACO06FEB]数字三角形Backward Digit Su…
- POJ3259--Wormholes(SPFA)
- 前端学习(十三)CSS margin的使用