android - 像网易贵金属安装之后的导航页动画如何做到不卡的
PHPz
PHPz 2017-04-17 16:40:44
0
2
370

我用了属性动画,但是在内存低的手机上跑了一下感觉卡卡的,但是贵金属的就不卡
,属性动画和补间动画相比效率上比较差吗,
这是我的代码

 private void setFirstAnimation() {
        if (firstAnimationState == 0) {
            firstAnimationState = 1;
            ObjectAnimator anim1 = ObjectAnimator.ofFloat(iv_first_calculator,
                    "x", PhoneParameterUtils.getScreenWidth() / 2f - 200f - 323f,
                    (PhoneParameterUtils.getScreenWidth() / 2f) - AppTools.dip2px(100)).setDuration(400);
            anim1.addListener(new Animator.AnimatorListener() {
                @Override
                public void onAnimationStart(Animator animator) {

                }

                @Override
                public void onAnimationEnd(Animator animator) {
                    AnimatorSet set = new AnimatorSet();

                    ObjectAnimator anim2 = ObjectAnimator.ofFloat(iv_first_ball,
                            "x", PhoneParameterUtils.getScreenWidth() / 2,
                            PhoneParameterUtils.getScreenWidth() / 2 + AppTools.dip2px(40)).setDuration(400);

                    ObjectAnimator anim3 = ObjectAnimator.ofFloat(iv_first_ball,
                            "y", PhoneParameterUtils.getScreenHeight() / 2 - AppTools.dip2px(120),
                            PhoneParameterUtils.getScreenHeight() / 2 - AppTools.dip2px(150)).setDuration(400);

                    set.playTogether(anim2, anim3);
                    set.addListener(new Animator.AnimatorListener() {
                        @Override
                        public void onAnimationStart(Animator animator) {
                            iv_first_ball.setVisibility(View.VISIBLE);
                        }

                        @Override
                        public void onAnimationEnd(Animator animator) {
                            AnimatorSet set = new AnimatorSet();
                            ObjectAnimator anim4 = ObjectAnimator.ofFloat(iv_first_man,
                                    "x", PhoneParameterUtils.getScreenWidth(),
                                    PhoneParameterUtils.getScreenWidth() / 2).setDuration(500);

                            ObjectAnimator anim5 = ObjectAnimator.ofFloat(iv_first_man,
                                    "x", PhoneParameterUtils.getScreenWidth() / 2,
                                    PhoneParameterUtils.getScreenWidth() / 2 + 10).setDuration(20);

                            ObjectAnimator anim6 = ObjectAnimator.ofFloat(iv_first_man,
                                    "x", PhoneParameterUtils.getScreenWidth() / 2 + 10,
                                    PhoneParameterUtils.getScreenWidth() / 2).setDuration(20);

                            set.playSequentially(anim4, anim5, anim6);
                            iv_first_man.setVisibility(View.VISIBLE);
                            set.addListener(new Animator.AnimatorListener() {
                                @Override
                                public void onAnimationStart(Animator animator) {

                                }

                                @Override
                                public void onAnimationEnd(Animator animator) {
                                    firstAnimationState = 0;
                                }

                                @Override
                                public void onAnimationCancel(Animator animator) {

                                }

                                @Override
                                public void onAnimationRepeat(Animator animator) {

                                }
                            });
                            set.start();
                        }

                        @Override
                        public void onAnimationCancel(Animator animator) {

                        }

                        @Override
                        public void onAnimationRepeat(Animator animator) {

                        }
                    });
                    set.start();

                }

                @Override
                public void onAnimationCancel(Animator animator) {
                }

                @Override
                public void onAnimationRepeat(Animator animator) {
                }
            });
            anim1.start();
        }
    }
PHPz
PHPz

学习是最好的投资!

全部回覆(2)
阿神

找到原因了,用了幾幅大的圖,放到了drawable-hdpi中的 囧啊

黄舟

也許人家直接是一個短片

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!