我應該怎麼做才能將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