• 一个发散动画的菜单控件(主要记录控件x,y坐标的运动状况)


     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 {
                //是奇数
            }
        }
  • 相关阅读:
    Codeforces 379 F. New Year Tree
    「NOI2018」屠龙勇士
    「NOI2018」归程
    深入理解Java枚举类型(enum)
    2018.6.9-学习笔记
    String、StringBuffer与StringBuilder介绍
    HashMap和HashTable到底哪不同?
    HashMap详解
    List,Set和Map详解及其区别和他们分别适用的场景
    Java中高级面试题(1)
  • 原文地址:https://www.cnblogs.com/yegong0214/p/9364363.html
Copyright © 2020-2023  润新知