问题描述
这就是我在画布上绘制图像的方式
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 (将#修改为@)