Android:ImageView上的Matrix操作,动画?

hzx*_*zxu 5 animation android translation matrix imageview

我正在使用矩阵来翻译/缩放ImageView,在setImageMatrix之后,结果直接显示,无论如何都要使它动画化?

谢谢!

Dhr*_*ola 1

放大将是平移和缩放的组合:

// 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);
Run Code Online (Sandbox Code Playgroud)

缩小将涉及放大时的反向插值器,之后您可以按照正常方式在图像视图上调用 startAnimation :

mZoomIn.setInterpolator(new ReverseInterpolator())
Run Code Online (Sandbox Code Playgroud)