我一直在瀏覽關於此主題的許多線程,我可以在Android 2.2中處理AnimationListeners時出現的閃爍中找到,但我無法完全解決我的問題。Android動畫閃爍
我得到的是一個LinearLayout'彈出窗口',用戶觸摸下移約100個像素,然後再次觸摸以將其移回。我終於在第一部分沒有任何閃爍的情況下工作了(感謝在視圖上調用clearAnimation()的建議),但是當做相反的操作時(即將視圖移回),閃爍開始。我無法在onAnimationStart()方法中真正調用clearAnimation(),因爲它不會動畫!當然,如果我使用setFillAfter()而沒有任何動畫偵聽器,但是視圖的觸摸區域不會移動(因爲視圖本身沒有「實際」移動),所有動畫都可以完美地工作。
任何幫助將不勝感激。
this.popoverTab.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
popoverTab.setClickable(false);
popoverTab.setFocusable(false);
if (popoverHidden) {
Log.d(TAG, "About to show popover");
// the popover is currently hidden, show it.
TranslateAnimation animation = new TranslateAnimation(0, 0, 100, 0);
animation.setDuration(700);
animation.setFillBefore(true);
animation.setAnimationListener(new AnimationListener() {
public void onAnimationEnd(Animation animation) {
}
public void onAnimationRepeat(Animation animation) {
}
public void onAnimationStart(Animation animation) {
footer.layout(footer.getLeft(), (footer.getTop() - 100), footer.getRight(), footer.getBottom());
}
});
footer.startAnimation(animation);
} else {
Log.d(TAG, "About to hide popover");
// the popover is showing, hide it.
TranslateAnimation animation = new TranslateAnimation(0, 0, 0, 100);
animation.setDuration(700);
animation.setFillAfter(true);
animation.setAnimationListener(new AnimationListener() {
public void onAnimationEnd(Animation animation) {
footer.clearAnimation();
footer.layout(footer.getLeft(), (footer.getTop() + 100), footer.getRight(), footer.getBottom());
}
public void onAnimationRepeat(Animation animation) {
}
public void onAnimationStart(Animation animation) {
}
});
footer.startAnimation(animation);
}
// invert.
popoverHidden = !popoverHidden;
popoverTab.setClickable(true);
popoverTab.setFocusable(true);
}
});
這需要被標記爲答案。 +1 – 2012-12-04 01:23:08
非常感謝你解決這個問題! – 2013-01-01 22:55:38
非常感謝。花了太多時間找到這個。 – braden 2013-07-11 01:47:02