1
보기를 터치하고 풀면 작은 애니메이션을 추가하기 위해 customView를 구현했습니다. 사용자가이보기를 클릭하면보기를 축소하는 80ms의 작은 애니메이션을 시작합니다.ACTION_CANCEL이 실행되지 않음
손가락이 위로 올 때 동일한 애니메이션이 재생됩니다 (역 효과). 시각적 효과가 뛰어나며 사용자가 손가락을 움직여보기를 떠나지 않는 한 올바르게 작동합니다. 손가락이 다시 애니메이션을 재생하는 내 경우에는 필요한보기 영역을 떠날 때
따라서, 난 그냥 ACTION_CANCEL에 대한 전화를받을 수 없습니다.
@Override
public boolean onTouchEvent(MotionEvent event) {
super.onTouchEvent(event);
switch (event.getAction()) {
case MotionEvent.ACTION_CANCEL: {
Animation anim = new ScaleAnimation(0.9f, 1f, 0.9f, 1f,
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
anim.setDuration(Utils.ANIM_CLICK_LENGHT);
anim.setFillAfter(true);
anim.setFillBefore(true);
startAnimation(anim);
break;
}
case MotionEvent.ACTION_DOWN: {
Animation anim = new ScaleAnimation(1f, 0.9f, 1f, 0.9f,
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
anim.setDuration(Utils.ANIM_CLICK_LENGHT);
anim.setFillAfter(true);
anim.setFillBefore(true);
startAnimation(anim);
break;
}
case MotionEvent.ACTION_UP: {
Animation anim = new ScaleAnimation(0.9f, 1f, 0.9f, 1f,
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
anim.setDuration(Utils.ANIM_CLICK_LENGHT);
anim.setFillAfter(true);
anim.setFillBefore(true);
startAnimation(anim);
break;
}
}
return true;
}
작품은 내가 오랫동안 찾아 봤는데, 당신에게 많이 감사합니다 :) – schusss