矢量图动画



一、定义静态矢量图 VectorDrawable

可以使用SVG类型的资源,也就是矢量图。设置到imageView中会显示出一个心形。控制显示心形的就是上面path这个标签,一个path代表一个元素,绘制的内容是pathData下的一长串字符,里面是SVG绘制的一系列命令,提供moveTo、lineTo、close等操作,可以和Graphics。 在xml文件中的标签是vector 。这里推荐一个SVG生成vectorDrawable的链接: http://inloop.github.io/svg2android/  地址。下载SVG格式链接: http://www.58pic.com/tupian/renwusvg.html vector_drawable_man.xml




二、给矢量图元素添加动画 AnimatedVectorDrawable

在xml文件中的标签是animated-vector

drawable/vector_animated_man.xml





三、定义动画文件 AnimatedVectorDrawable

在xml文件中的标签是 set






Java 动画设置
mImageView = (ImageView) findViewById(R.id.image_view);mImageView.setImageDrawable(getResources().getDrawable(R.drawable.vector_animated_man, null));Drawable drawable = mImageView.getDrawable();if (drawable instanceof AnimatedVectorDrawable) {((AnimatedVectorDrawable) drawable).start();}





本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部