【发布时间】:2012-10-26 15:43:56
【问题描述】:
我们正在使用 TouchImageView 并希望实现 onDoubleTap 缩放... 到目前为止一切顺利。
问题是:
如果我们应用缩放动画并设置setFillAfter(false),在AnimationListener.onAnimationEnd中,我们将正确的矩阵应用到imageview 和 一切都按预期工作(滚动、其他缩放手势等)。 -> 但是 - 你会在屏幕上看到一个小的闪烁(这是可以理解的 - 因为动画会跳回到开头,然后会应用矩阵更改)
另一方面,如果setFillEnabled(true),动画看起来很棒,没有闪烁,但不知何故视图完全混乱,起初一切看起来都很棒,但是最大和最小缩放级别完全搞砸了 - 你不能再缩小到初始缩放,而且移动图片不起作用正如预期的那样 - 边界是错误的?类似的东西)
那么我们的问题 ;)?
- 带有 setFillAfter(true) 的 ScaleAnimation 实际上有什么作用?
- 它会改变(完整)图像视图的大小吗?
- 出了什么问题:/?
一如既往地非常感谢您的帮助 :=) 干杯,
//顺便说一句:在所有 android 版本 中都会发生这种情况,在 4.1 上,所描述的问题不会出现,并且一切都按预期工作。
---------------
更新:
所以当前的代码是这样的,可以工作,(缩放不再有问题)但是在设置矩阵和清除动画之间有一个小的“闪烁”(尽管)代码显示,它应该应用矩阵 -before - 动画被清理了,所以我希望无缝过渡...
感谢您的回复!
Log.v("TouchImageView", "Zoom in");
ScaleAnimation zoomIn = new ScaleAnimation(saveScale, SCALE_DOUBLE_TAP, saveScale, SCALE_DOUBLE_TAP, width / 2, height / 2);
zoomIn.setDuration(200);
zoomIn.setFillAfter(true);
zoomIn.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
isAnimating = true;
saveScale = SCALE_DOUBLE_TAP;
right = width * saveScale - width - (2 * redundantXSpace * saveScale);
bottom = height * saveScale - height - (2 * redundantYSpace * saveScale);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
isAnimating = false;
matrix.postScale(SCALE_DOUBLE_TAP, SCALE_DOUBLE_TAP, width / 2, height / 2);
matrix.getValues(matrixValues);
setImageMatrix(matrix);
clearAnimation();
}
});
startAnimation(zoomIn);
【问题讨论】:
标签: android animation matrix touch imageview