I have an ImageView. I want to:
1 – shrink the view
2 – change the image resource
3 – scale back the view
I tried to this in the following section of code, but this is not working. It behaves like the 3rd row doesn’t exist. Can someone tell me what I’m doing wrong?
Animation anim = AnimationUtils.loadAnimation(this, R.anim.scale);
Animation animo = AnimationUtils.loadAnimation(this, R.anim.scale_out);
i.startAnimation(anim);
i.setImageResource(R.drawable.logoc);
i.startAnimation(animo);
scale.xml:
<?xml version="1.0" encoding="utf-8"?>
<scale xmlns:android="http://schemas.android.com/apk/res/android"
android:fromXScale="1.0"
android:toXScale="0.125"
android:fromYScale="1.0"
android:toYScale="0.125"
android:pivotX="50%"
android:pivotY="50%"
android:startOffset="0"
android:duration="400"
android:fillBefore="true" />
scale_out.xml:
<?xml version="1.0" encoding="utf-8"?>
<scale xmlns:android="http://schemas.android.com/apk/res/android"
android:fromXScale="1.0"
android:toXScale="4.0"
android:fromYScale="1"
android:toYScale="4.0"
android:startOffset="400"
android:pivotX="50%"
android:pivotY="50%"
android:duration="800"
/>
I think you should try doing this way:
Edit:
Ok, I was wrong: This works: