I am trying to do some simple image zooming and panning with Android and I have two simple questions.
First, when I call the animation using scale, it zooms using the upper left-hand corner of the image as the origin but I would like it to zoom from the center of the image.
The second question is once the animation is done, it resets the image to the original state and I would like it to stay at the final state.
Here is the xml I have for the scale:
<scale android:fromXScale="1.0"
android:fromYScale="1.0"
android:toXScale="2.0"
android:toYScale="2.0"
android:detachWallpaper="true"
android:duration="3000"></scale>
and in my code:
a = AnimationUtils.loadAnimation(this, R.anim.set);
a.reset();
ImageView iv = (ImageView) findViewById(R.id.imageView1);
iv.clearAnimation();
iv.startAnimation(a);
For scaling a image from center you have to set the pivotX and pivotY
try this code for scaling from center and retaining the state after scaling,
Thanks…