webView 与 旋转动画 Animation问题

来源:互联网 发布:2017淘宝处罚考试答案 编辑:程序博客网 时间:2024/05/21 09:23

loading 动画 旋转的图片出现渲染问题 

毕现 方法是 打开webView 然后所有的loading页  转转转的动画图片 渲染会有问题

(目前只发现 小米3 有这个问题)


解决方法

if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {

        loadingImageView.setLayerType(View.LAYER_TYPE_SOFTWARE,null);

        }






部分代码


 public void onCreate(BundlesavedInstanceState) {

        super.onCreate(savedInstanceState);

        initRoateAnimation();

}


private void initRoateAnimation(){

        operatingAnim = AnimationUtils.loadAnimation(getActivity(), R.anim.repeatrotate);

        LinearInterpolator lin = new LinearInterpolator();

        operatingAnim.setInterpolator(lin);

        operatingAnim.setFillAfter(true);

    }



    @SuppressLint("NewApi")

@Override

    public View onCreateView(LayoutInflaterinflater, ViewGroupcontainer, BundlesavedInstanceState) {

        View view = inflater.inflate(R.layout.fragment_hf_loading,container,false);

        loadingImageView = (ImageView) view.findViewById(R.id.loading_image);

        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {

        loadingImageView.setLayerType(View.LAYER_TYPE_SOFTWARE,null);

        }

     return view;

    }




    public void setLoadingSwitchON(booleanisSwitchON) {

        if(switchON &&isSwitchON){

            return;

        }

        switchON = isSwitchON;

        if(switchON){

            LogUtil.v(TAG,"打开loadingView");

            new Handler().postDelayed(new Runnable() {

                @Override

                public void run() {

//                    startEnlargeAnimation(1);

                    loadingImageView.startAnimation(operatingAnim);

                }

            },100);

        }else{

            loadingImageView.clearAnimation();

        }

    }


0 0