Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了android – 旋转动画后保存图像时如何避免闪烁图像?大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我混淆了翻译动画和旋转动画.在我的游戏中我使用这两个动画,完成动画后我保存了我的图像.在翻译动画中它很好,但在完成旋转动画后,我的图像闪烁一次.请看下面的代码,请解决我的问题……

为什么有人不回答我的问题,这是不明白的,或者我在问任何错误的问题?请告诉我原因……………..

谢谢.

Bitmap bmp=BitmapFactory.decoderesource(getresources(),R.drawable.Train); 
//1)
TranslateAnimation TAnimation=new TranslateAnimation(0,-100);//bottom to start
        TAnimation.seTinterpolator(new LinearInterpolator());
        TAnimation.setDuration(2000);
        TAnimation.setFillAfter(false);
        TAnimation.setFillEnabled(true);
        //TAnimation.setFillBefore(true);
        Train.startAnimation(TAnimation);

TAnimation.setAnimationListener(new AnimationListener() {

            public void onAnimationStart(Animation animation) {

            }

            public void onAnimationRepeat(Animation animation) {

            }

            public void onAnimationEnd(Animation animation) {

                RelativeLayout RL=(RelativeLayout)findViewById(R.id.rl);
                    param=new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
                param.setMargins(x,y,0);
                    Train.setLayoutParams(param);
                    Train.setImageBitmap(bmp);       
            }
        });
    //x and y values are exact position of compliTing translateanimation position 
//2)
RotateAnimation RAnimation=new RotateAnimation(0,90,50,25);
        RAnimation.seTinterpolator(new LinearInterpolator());
        RAnimation.setDuration(2000);
        RAnimation.setFillAfter(false);
        TAnimation.setFillEnabled(true);
        //RAnimation.setFillBefore(true);
        Train.startAnimation(RAnimation);
RAnimation.setAnimationListener(new AnimationListener() {

            public void onAnimationStart(Animation animation) {

            }

            public void onAnimationRepeat(Animation animation) {

            }
            public void onAnimationEnd(Animation animation) {
                RelativeLayout RL=(RelativeLayout)findViewById(R.id.rl);
                    param=new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT,0);//x and y values are exact position of compliTing translateanimation position 
                    Train.setLayoutParams(param);
                    Train.setImageBitmap(bmp);
                }
        });
@H_674_14@解决方法
我遇到了这个问题,但它的修复非常简单.你不需要实现动画监听器,简单的不要这样做(我有你的问题,因为我使用这种方式).

做动画并在调用动画方法之前:
setFillAfter(真); //这个动画结尾处的保存视图

像这样:

//my animation
final Animation rotation = AnimationUtils.loadAnimation(getActivity(),R.anim.rotate_up);
//hide login content
content.setVisibility(View.GONE);
//animContent = AnimationUtils.loadAnimation(getActivity(),R.anim.show_up);
rotation.setFillAfter(true);
//animate the arrow
arrow.startAnimation(rotation);

因此,删除侦听器并将setFillAfter(false)更改为TRUE.会工作;)

大佬总结

以上是大佬教程为你收集整理的android – 旋转动画后保存图像时如何避免闪烁图像?全部内容,希望文章能够帮你解决android – 旋转动画后保存图像时如何避免闪烁图像?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。