我应该怎么做才能将imageButton移动到新的位置并保持OnClick事件?ImageButton移动后的OnClickListener问题TranslateAnimation
我对这两个问题:
- 如果我使用fillAfter(真),的onclick不会带到新的地方。
- 如果使用setAnimationListener(onAnimationEnd),并调用layout()将ImageButton移动到新的位置,ImageButton将返回到新的开始位置,为什么?
代码在这里:
tsla = new TranslateAnimation(0.0f,(float) (imgWidth * 0.45)-wh/2,0.0f,(float) (imgHeight * 0.566666667)-wh/2);
tsla.setDuration(sleepX);
tsla.setAnimationListener(new AnimationListener(){
public void onAnimationStart(Animation arg0) {
}
public void onAnimationEnd(Animation arg0) {
imgBtnChengdu.layout(
(int) (imgWidth * 0.45),
(int) (imgHeight * 0.566666667),
(int) (imgWidth - wh - imgWidth * 0.45),
(int) (imgHeight - wh - imgHeight * 0.566666667)
);
}
public void onAnimationRepeat(Animation arg0) {
}
});
imgBtnChengdu.setAnimation(tsla);
谢谢,Janusz ... – SICON 2012-04-16 02:41:36