Я тратил столько потоков на эту тему, что я могу найти на мерцание, которое возникает в Android 2.2 при работе с AnimationListeners, но я не могу решить мою проблему.Android Animation Flicker
У меня есть LinearLayout 'popover', который пользователь прикасается, чтобы опуститься примерно на 100 пикселей, и снова коснется его, чтобы переместить его обратно. Я, наконец, начал работать над первой частью без какого-либо мерцания (благодаря предложению вызывать clearAnimation() на анимированном представлении), но при выполнении противоположного (т. Е. Перемещение представления назад) есть мерцание начало. Я не могу называть clearAnimation() в методе onAnimationStart(), поскольку он не будет анимировать!
Конечно, вся анимация работает отлично, если я использовал 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 –
Большое вам спасибо за решение этой проблемы! –
Большое спасибо. Я слишком долго искал это. – braden