Problemy z OnClickListener po przeniesieniu ImageButton po TranslateAnimation
co powinienem zrobić, aby przesunąć przycisk ImageButton na nowe miejsce i zachować zdarzenie OnClick?
Mam na ten temat dwa pytania:
Jeśli użyję fillAfter (true), onclick nie zostanie przeniesiony do nowego miejsca.Jeśli użyjesz setAnimationListener (onAnimationEnd) i układu połączeń (), aby przenieść ImageButton w nowe miejsce, ImageButton powróci do nowego miejsca początkowego, dlaczego?kody tutaj:
<code> 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); </code>