Tôi đã rà soát qua nhiều chủ đề về chủ đề này mà tôi có thể tìm thấy trên nhấp nháy phát sinh trong Android 2.2 khi giao dịch với AnimationListeners, nhưng tôi không thể giải quyết được vấn đề của mình.Android Animation Flicker
Tôi đã có một cửa sổ bật lên 'LinearLayout' mà người dùng chạm để di chuyển xuống khoảng 100 pixel và chạm lại để di chuyển nó trở lại. Cuối cùng, tôi đã làm việc trên phần đầu tiên mà không có bất kỳ nhấp nháy nào (nhờ lời đề nghị gọi clearAnimation() trên chế độ xem đang hoạt hình), nhưng khi thực hiện ngược lại (nghĩa là di chuyển chế độ xem lên), có một nhấp nháy tại bắt đầu. Tôi không thể gọi clearAnimation() trong phương thức onAnimationStart() vì nó sẽ không hoạt ảnh! Tất nhiên, tất cả hoạt ảnh hoạt động hoàn hảo nếu tôi sử dụng setFillAfter() mà không có bất kỳ trình nghe hoạt hình nào, nhưng vùng cảm ứng của khung nhìn sẽ không di chuyển (vì chính chế độ xem đó không thực sự được di chuyển).
Mọi trợ giúp sẽ được đánh giá cao.
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);
}
});
Điều này cần được đánh dấu là câu trả lời. +1 –
Cảm ơn bạn rất nhiều vì đã giải quyết vấn đề này! –
Cảm ơn rất nhiều. Đã cho tôi quá lâu để tìm thấy điều này. – braden