OnclickListener为动画视图 [英] OnclickListener for Animated View
问题描述
发现同样的问题,很多的问题。
found many question on same issue.
<一个href=\"http://stackoverflow.com/questions/6743290/how-to-set-onclicklistener-on-the-imageview-after-rotation-animation\">How设置OnClickListener在ImageView的旋转动画后
<一个href=\"http://stackoverflow.com/questions/8713020/how-to-write-the-onclick-listener-for-a-view-after-animation\">How写的onclick侦听器动画后有何看法?
我也有同样的问题,有何建议?
i also have same issue, any suggestion ?
推荐答案
您应该写关于你的具体问题清新,简洁的问题,而不是仅仅指向其他问题。联系到这两个问题是不完全清楚。
You ought to write a fresh, concise question about your specific issue rather than just pointing to other questions. The two questions linked to aren't entirely clear.
我想你的问题是应用动画(如 TranslateAnimation
,例如)到后查看
的查看
不再响应触摸事件在新的位置。这样做的原因是因为查看
尚未在布局参数方面移动到新的位置,而是已应用的转换。
I assume your issue is that after applying an animation (such as a TranslateAnimation
, for example) to a View
, the View
no longer responds to touch events in its new position. The reason for this is because the View
hasn't been moved to the new position in terms of layout parameters, but rather it has had a transformation applied.
解决的办法很简单:在动画完成后立即,实际移动查看
到新的位置。您可以设置 myAnimation.setFillAfter()= FALSE
,并设置一个监听器物理移动查看
的目标位置当动画结束:
The solution is quite simple: immediately after the animation has completed, actually move the View
to the new position. You could set myAnimation.setFillAfter() = false
, and set a listener to physically move the View
to the target location when the animation has finished:
myAmazingAnimation.setFillAfter() = false;
myAmazingAnimation.setAnimationListener(new Animation.AnimationListener(){
@Override
public void onAnimationEnd(Animation animation) {
// Now actually move the View using LayoutParams
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationStart(Animation animation) {
}
});
另一个变化是应用于动画之前在开始时身体移动查看
和然后的应用动画,使查看
启动它曾经是,在 0,0
结束。
Another variation is to physically move the View
at the beginning before animation is applied, and then apply an animation that makes the View
start where it used to be and end at 0,0
.
这篇关于OnclickListener为动画视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!