我正在使用矩阵来平移/缩放 ImageView,设置 ImageMatrix 后,结果直接显示,是否有任何方式使其动画化?
谢谢!
最佳答案
放大将是平移和缩放的组合:
// 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);
缩小将涉及放大时的反向插值器,之后您可以按照正常方式在 ImageView 上调用 startAnimation:
mZoomIn.setInterpolator(new ReverseInterpolator())
关于Android:ImageView 上的矩阵运算,动画?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6248052/