private void showCloseAnim() {
        int size = viewList.size();
        if (size % 2 == 0) {
            //是偶数
            for (int i = 0; i < size; i++) {
                if (i < size / 2) {
                    //坐标轴下边
                    AnimatorSet set = new AnimatorSet();
                    double x = -Math.cos(Math.PI * (size - 1 - 2 * i) / (4 * size - 4)) * 600;
                    double y = Math.sin(Math.PI * (size - 1 - 2 * i) / (4 * size - 4)) * 600;
                    set.playTogether(ObjectAnimator.ofFloat(viewList.get(i), "translationX", (float) x, 0),
                            ObjectAnimator.ofFloat(viewList.get(i), "translationY", (float) y, 0));
                    set.setInterpolator(new BounceInterpolator());
                    set.setDuration(500).setStartDelay(100 * i);
                    set.start();
                    
                } else {
                    //坐标轴上边
                    AnimatorSet set = new AnimatorSet();
                    double x = -Math.cos(Math.PI * (2 * i - size + 1) / (4 * size - 4)) * 600;
                    double y = -Math.sin(Math.PI * (2 * i - size + 1) / (4 * size - 4)) * 600;
                    set.playTogether(ObjectAnimator.ofFloat(viewList.get(i), "translationX", (float) x, 0),
                            ObjectAnimator.ofFloat(viewList.get(i), "translationY", (float) y, 0));
                    set.setDuration(500).setStartDelay(100 * i);
                    set.start();
                }
            }
            
            
        } else {
            //是奇数
        }
    }
    
    private void showOpenAnim() {
        int size = viewList.size();
        if (size % 2 == 0) {
            //是偶数
            for (int i = 0; i < size; i++) {
                if (i < size / 2) {
                    //坐标轴下边
                    AnimatorSet set = new AnimatorSet();
                    double x = -Math.cos(Math.PI * (size - 1 - 2 * i) / (4 * size - 4)) * 600;
                    double y = Math.sin(Math.PI * (size - 1 - 2 * i) / (4 * size - 4)) * 600;
                    set.playTogether(ObjectAnimator.ofFloat(viewList.get(i), "translationX", 0, (float) x),
                            ObjectAnimator.ofFloat(viewList.get(i), "translationY", 0, (float) y),
                            ObjectAnimator.ofFloat(viewList.get(i), "alpha", 0, 1).setDuration(2000));
                    set.setDuration(500).setStartDelay(100 * i);
                    set.start();
                    
                } else {
                    //坐标轴上边
                    AnimatorSet set = new AnimatorSet();
                    double x = -Math.cos(Math.PI * (2 * i - size + 1) / (4 * size - 4)) * 600;
                    double y = -Math.sin(Math.PI * (2 * i - size + 1) / (4 * size - 4)) * 600;
                    set.playTogether(ObjectAnimator.ofFloat(viewList.get(i), "translationX", 0, (float) x),
                            ObjectAnimator.ofFloat(viewList.get(i), "translationY", 0, (float) y),
                            ObjectAnimator.ofFloat(viewList.get(i), "alpha", 0, 1).setDuration(2000));
                    set.setDuration(500).setStartDelay(100 * i);
                    set.start();
                }
            }
            
            
        } else {
            //是奇数
        }
    }

 

posted on 2018-07-25 10:09  从前有個人  阅读(142)  评论(0编辑  收藏  举报