我有可缩放的图像,我使用的是ScaleGestureDetector.SimpleOnScaleGestureListener。我需要实施以下项目:
我有点问题。在双拍之前总是单拍和图片放大,但出现烤面包。有什么办法可以避免单打吗?我没有足够的智慧来解决这个问题。
P.S. i不能使用 ScaleGestureDetector.SimpleOnScaleGestureListener,因为使用ScaleGestureDetector.SimpleOnScaleGestureListener。
UPD
case MotionEvent.ACTION_UP:
firstTime = System.currentTimeMillis();
if (Math.abs(firstTime-secondTime) < 300L) {
// scale my matrix
---//---
DONE = true; //this flag symbolize, that toast doesn't appear (false - appears)
}
else if (!DONE) {
// making toast
}
secondTime = firstTime;
break;当DoubleTap启用图像缩放,但出现吐司
发布于 2012-05-27 17:24:11
@ thank 5784,谢谢。我解决了我的问题。
case MotionEvent.ACTION_UP:
float xDiff = Math.abs(curr.x - start.x);
float yDiff = Math.abs(curr.y - start.y);
firstTime = System.currentTimeMillis();
if (Math.abs(firstTime-secondTime) > 200L) {
myHand.postDelayed(mRun, 200);
}
else if (!DONE) {
//scale my matrix
DONE = true; //this flag symbolize, that toast doesn't appear (false - appears)
}
secondTime = firstTime;
break;
Handler myHand = new Handler();
private Runnable mRun = new Runnable() {
@Override
public void run() {
if (!DONE) {
// make toast
}
} 发布于 2012-05-24 14:47:40
我建议实现一个延迟,即信息不会在单个点击时立即弹出,但只有当信息在合理的时间内没有遇到第二个点击时才会显示(可能不管双击的阈值是多少)。也就是说,如果设置为在.2秒内将任何点击注册为双击,则在等待.2秒之前不要显示信息,并确保没有双击。
替代解决方案(可能不太有用)--让双击/缩放函数调用任何使信息框消失的函数。然而,它可能仍然会弹出很短的时间,这可能看起来很傻/有问题。
https://stackoverflow.com/questions/10739662
复制相似问题