播放动画前ImageView中图片会闪一下怎么破

先上代码:

Rect visibleRect =  new Rect();

                oldImage.getLocalVisibleRect(visibleRect);

                rectFrom = new Rect(visibleRect);
                rectTo = new Rect(visibleRect);
                rectTo.top = 433;
                rectTo.bottom = 899;

                rectFromNew = new Rect(visibleRect);
                rectFromNew.top = -433;
                rectFromNew.bottom = 0;
                rectToNew = new Rect(visibleRect);

                oldImage.setVisibility(View.VISIBLE);
                newImage.setVisibility(View.VISIBLE);

                oldImage.setImageResource(R.drawable.old);
                newImage.setImageResource(R.drawable.new);

                Animator animatorOld = ObjectAnimator.ofObject(oldImage, "clipBounds", new RectEvaluator(), rectFrom, rectTo);
                Animator animatorNew = ObjectAnimator.ofObject(newImage, "clipBounds", new RectEvaluator(),rectFromNew, rectToNew );



                Animator.AnimatorListener listenerOld = new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animator) {

                    }

                    public void onAnimationStart(Animator animator) {


                    }

                    public void onAnimationRepeat(Animator animator) {


                    }

                };


                Animator.AnimatorListener listenerNew = new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animator) {

                    }

                    public void onAnimationStart(Animator animator) {

                    }

                    public void onAnimationRepeat(Animator animator) {

                    }

                };

                animatorOld.addListener(listener);
                animatorNew.addListener(listenerNew);

                animatorOld.setDuration(SOME_TIME);
                animatorNew.setDuration(SOME_TIME);
                animatorOld.start();
                animatorNew.start(); 


我想在两个重叠的图片上实现ppt那种擦除交替的效果,现在效果是有了,但是在播放动画之前新的图片总是会闪一下,然后消失,然后正常播放动画。那几个动画监听器我都试过了,在里面放上

setVisibility(View.INVISIBLE);

诸如此类的语句等等,一点点用都没有,弄得我都开始怀疑人生了。其中一个我试的是在layout里面把新图片默认设为invisible,然后监听器里面在onAnimationStart放入

setVisibility(View.VISIBLE);

按照道理应当是动画开始播放后新图片才可见,但是没用,依旧是有个一闪而过的过程。

谁能跑下我的代码看看问题如何解决?那个动画开始前的一瞬间新图片闪一下必须得去掉。
2018-08-10 18:04 添加评论 分享
已邀请:

要回复问题请先登录注册

退出全屏模式 全屏模式 回复