本文介绍了Android的动画闪烁的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经拖网通过这个话题,我可以找到,当与AnimationListeners处理出现在Android 2.2的闪烁尽可能多的线程,但我不能完全解决我的问题。

我已经有了一个LinearLayout中popover用户触摸向下移动大约100个​​像素,并再次触及移动它备份。我终于懂了工作在第一部分,没有任何闪烁(感谢的建议,呼吁clearAnimation()上进行动画视图),但这样做的相反(即移动视图备份),有一个闪烁的时候开始。我真的不能叫clearAnimation()在onAnimationStart()方法,因为它不会动画!

当然,所有的动画作品完美,如果我用setFillAfter()没有任何动画监听器,但随后的视图的触摸区域不会移动(因为观点本身并没有真正移动)。

任何帮助将是很大的AP preciated。

  this.popoverTab.setOnClickListener(新OnClickListener(){
    公共无效的onClick(视图v){
        popoverTab.setClickable(假);
        popoverTab.setFocusable(假);
        如果(popoverHidden){
            Log.d(TAG,关于以示popover);
            //在popover当前处于隐藏状态,显示它。
            TranslateAnimation动画=新TranslateAnimation(0,0,100,0);
            animation.setDuration(700);
            animation.setFillBefore(真正的);
            animation.setAnimationListener(新AnimationListener(){
                公共无效onAnimationEnd(动画动画){

                }

                公共无效onAnimationRepeat(动画动画){

                }

                公共无效onAnimationStart(动画动画){
                    footer.layout(footer.getLeft(),(footer.getTop() -  100),footer.getRight(),footer.getBottom());
                }
            });
            footer.startAnimation(动画);
        } 其他 {
            Log.d(TAG,关于隐藏popover);
            //在popover显示时,将其隐藏。
            TranslateAnimation动画=新TranslateAnimation(0,0,0,100);
            animation.setDuration(700);
            animation.setFillAfter(真正的);
            animation.setAnimationListener(新AnimationListener(){
                公共无效onAnimationEnd(动画动画){
                    footer.clearAnimation();
                    footer.layout(footer.getLeft(),(footer.getTop()+ 100),footer.getRight(),footer.getBottom());
                }

                公共无效onAnimationRepeat(动画动画){

                }

                公共无效onAnimationStart(动画动画){

                }
            });
            footer.startAnimation(动画);
        }
        // 倒置。
        !popoverHidden = popoverHidden;
        popoverTab.setClickable(真正的);
        popoverTab.setFocusable(真正的);
    }

});
 

解决方案

我有同样的问题,几天后,我找到了解决办法...感谢名单为:

http://www.mail-archive.com/android-developers@googlegroups.com/msg67535.html

I've been trawling through as many threads on this topic that I can find on the flicker that arises in Android 2.2 when dealing with AnimationListeners, but I can't quite solve my issue.

What I've got is a LinearLayout 'popover' that the user touches to move down about 100 pixels, and touches again to move it back up. I've finally got it working on the first part without any flicker (thanks to the suggestion to call clearAnimation() on the view being animated), but when doing the opposite (ie, moving the view back up), there's a flicker at the start. I can't really call clearAnimation() in the onAnimationStart() method as it won't animate!

Of course, all animation works perfectly if I used setFillAfter() without any animation listener, but then the view's touch area won't move (because the view itself hasn't "actually" moved).

Any help would be greatly appreciated.

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 had the same problem and after few days I found the solution ... thanx to:

http://www.mail-archive.com/android-developers@googlegroups.com/msg67535.html

这篇关于Android的动画闪烁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-07 00:00
查看更多