Android:ImageView 上的矩阵运算,动画?

标签 android animation matrix translation imageview

我正在使用矩阵来平移/缩放 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/

相关文章:

r - R 和替代方案中的循环

android - 上传到市场后移动到 Sd 不起作用

android - Dagger 2 构造函数注入(inject)等

java - "Display over other apps"

java - 在 Android 中打包/传输 EventObject

Java基本2d游戏动画卡顿

c# - 如何在 WPF 中为图像缩放变化设置动画?

html - 自定义动画仅在 Chrome/Opera 中不适用于内联元素

matrix - 使用 cuSolver 计算一般矩阵的逆的最有效方法是什么?

c++ - 在 C++ 中创建基本矩阵的困难