PAG动画简单使用

相关文档
使用案例
1.https://developer.51cto.com/article/698498.html
2.https://blog.csdn.net/qq_43127921/article/details/122532148
3.https://pag.io/ 官网

     layGift = (LinearLayout) findViewById(R.id.lay_gift);
        pagView = new PAGView(GetGiftBagActivity.this);
        if (!pagView.isPlaying()) {
            layGift.addView(pagView);
            WindowManager manager = this.getWindowManager();
            DisplayMetrics outMetrics = new DisplayMetrics();
            manager.getDefaultDisplay().getMetrics(outMetrics);
            int width = outMetrics.widthPixels;
            int height = outMetrics.heightPixels;
            PAGComposition pagComposition = PAGComposition.Make(width, height);
            file = PAGFile.Load(getAssets(), type);
            Matrix matrix1 = new Matrix();
            pagView.setScaleMode(PAGScaleMode.Zoom);
            file.setMatrix(matrix1);
            file.setDuration(duration);
            pagComposition.addLayerAt(file, 0);
            pagView.setComposition(pagComposition);
            pagView.setRepeatCount(rePeatCont);
            pagView.play();

        pagView.addListener(new PAGView.PAGViewListener() {
            @Override
            public void onAnimationStart(PAGView pagView) {
                LogUtil.i(TAG, "onAnimationStart");
            }

            @Override
            public void onAnimationEnd(PAGView pagView) {
                LogUtil.i(TAG, "onAnimationEnd");
                screenStayClear();
                if (isGetAnimation) {
                    showDialogPackageInformation(packageInformation);
                } else {
                    showChangeSuccessDialog();
                }
            }

            @Override
            public void onAnimationCancel(PAGView pagView) {
                LogUtil.i(TAG, "onAnimationCancel");
            }

            @Override
            public void onAnimationRepeat(PAGView pagView) {
                LogUtil.i(TAG, "onAnimationRepeat");
            }
        });
    }
        }





 	// 平移动画 向下平移
 translateAnimation = new TranslateAnimation(TranslateAnimation.ABSOLUTE, 0f, TranslateAnimation.ABSOLUTE, 0f, TranslateAnimation.RELATIVE_TO_PARENT, -1f, TranslateAnimation.RELATIVE_TO_PARENT, 0f);
        translateAnimation.setDuration(1300);
        translateAnimation.setRepeatCount(-1);
        translateAnimation.setInterpolator(new DecelerateInterpolator());
        ivGrid.setAnimation(translateAnimation);

你可能感兴趣的:(动画,java,开发语言)