zoukankan      html  css  js  c++  java
  • 一个发散动画的菜单控件(主要记录控件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 {
                //是奇数
            }
        }
  • 相关阅读:
    一行代码更改博客园皮肤
    fatal: refusing to merge unrelated histories
    使用 netcat 传输大文件
    linux 命令后台运行
    .net core 使用 Nlog 配置文件
    .net core 使用 Nlog 集成 exceptionless 配置文件
    Mysql不同字符串格式的连表查询
    Mongodb between 时间范围
    VS Code 使用 Debugger for Chrome 调试vue
    css权重说明
  • 原文地址:https://www.cnblogs.com/yegong0214/p/9364363.html
Copyright © 2011-2022 走看看