I am using matrix to translate/scale an ImageView, after setImageMatrix, the result is shown directly, is there anyway to make it animated?
Thanks!
Zooming in would be a combination of both translate and scale:
// zooms in to the center of the screen
mZoomIn = new AnimationSet(true);
mTranslate = new TranslateAnimation(
Animation.ABSOLUTE, 0.0f, Animation.ABSOLUTE, -imageViewXCoord/(mScreenWidth/mImageViewWidth),
Animation.ABSOLUTE, 0.0f, Animation.ABSOLUTE, -imageViewYCoord/(mScreenWidth/mImageViewWidth)
);
mTranslate.setDuration(200);
mScale = new ScaleAnimation(1, mScreenWidth/mImageViewWidth, 1, mScreenWidth/mImageViewWidth);
mScale.setDuration(200);
mZoomIn.addAnimation(mTranslate);
mZoomIn.addAnimation(mScale);
mZoomIn.setFillAfter(true);
mZoomIn.setFillEnabled(true);
mImageView.startAnimation(mZoomIn);
Zooming out would involve a reverse interpolator on the zoom in, after which you can call startAnimation on your image view as per normal:
mZoomIn.setInterpolator(new ReverseInterpolator())
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With