如何解决在画布上绘制动画放大和缩小图像
这就是我在画布上绘制图像的方式
Drawable d1 = getResources().getDrawable(R.drawable.foobar1,null);
Drawable d2 = getResources().getDrawable(R.drawable.foobar2,null);
d1.setBounds(left,top,right,bottom);
d2.setBounds(left,bottom);
d1.draw(canvas);
d2.draw(canvas);
我尝试过这种动画制作方法。
ImageView mThumbDrawable1= new ImageView(context);;
ImageView mThumbDrawable2= new ImageView(context);
mThumbDrawable1.setimageDrawable(d1);
mThumbDrawable2.setimageDrawable(d2);
Animation zoomin = AnimationUtils.loadAnimation(getContext(),R.anim.zoomin);
Animation zoomout = AnimationUtils.loadAnimation(getContext(),R.anim.zoomout);
mThumbDrawable1.setAnimation(zoomin);
mThumbDrawable2.setAnimation(zoomout);
mThumbDrawable1.startAnimation(zoomin);
mThumbDrawable2.startAnimation(zoomout);
zoomin.xml
<?xml version="1.0" encoding="utf-8"?>
<scale xmlns:android="http://schemas.android.com/apk/res/android"
android:fromXScale="0.5"
android:toXScale="1.5"
android:fromYScale="0.5"
android:toYScale="1.5"
android:pivotX="50%"
android:pivotY="50%"
android:duration="1000"
android:fillAfter="true">
</scale>
zoomout.xml
<?xml version="1.0" encoding="utf-8"?>
<scale xmlns:android="http://schemas.android.com/apk/res/android"
android:fromXScale="1.5"
android:toXScale="0.5"
android:fromYScale="1.5"
android:toYScale="0.5"
android:pivotX="50%"
android:pivotY="50%"
android:duration="2000"
android:fillAfter="true">
</scale>
但它不起作用。但是如果我使用 view 来设置动画而不是 drawable 它确实有效。喜欢
Animation zoomin = AnimationUtils.loadAnimation(getContext(),android.R.anim.zoomin);
Animation zoomout = AnimationUtils.loadAnimation(getContext(),android.R.anim.zoomout);
this.setAnimation(zoomin);
this.startAnimation(zoomin);
但这与预期的结果相去甚远。 iam试图在检查和未选中按钮时从一个可绘制的滑动到另一个滑动。任何帮助是极大的赞赏。感谢您阅读我的问题。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。