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 {
                //是奇数
            }
        }
  • 相关阅读:
    圆的国度:Can you understand what you see?
    P5732 杨辉三角
    Django中与CSRF相关的内容
    Python中一些可能会问到的面试题
    python协程,线程的其他方法
    python 线程
    python-进程-其他方法(2)
    python 进程的一些其他方法
    python进程--传参,for循环创建,join方法
    python并发编程
  • 原文地址:https://www.cnblogs.com/yegong0214/p/9364363.html
Copyright © 2011-2022 走看看