zoukankan      html  css  js  c++  java
  • Android属性动画-简单实例

    1.ValueAnimator

    //在2000毫秒内,将值从0过渡到1的动画
            ValueAnimator anim = ValueAnimator.ofFloat(0f, 1f);
            anim.setDuration(2000);
            anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                @Override
                public void onAnimationUpdate(ValueAnimator valueAnimator) {
                    float currentValue = (float) valueAnimator.getAnimatedValue();
                    Log.e("tag", "currentValue="+currentValue);
                    String textStr = ((int) (currentValue * 60)) + "";
                    text1_tv.setText(textStr);
                }
            });
            anim.start();

    2.ObjectAnimator

    //将TextView从常规变换成全透明,再从全透明变换成常规
            ObjectAnimator anim1 = ObjectAnimator.ofFloat(text2_tv, "alpha", 1f, 0f, 1f);
            anim1.setDuration(3000);
            anim1.start();
            //将TextView进行一次360度的旋转
            ObjectAnimator anim2 = ObjectAnimator.ofFloat(text2_tv, "rotation", 0f, 360f);
            anim2.setDuration(3000);
            anim2.start();
            //将TextView先向左移出屏幕,然后再移动回来
            float curTranslationX = text2_tv.getTranslationX();
            ObjectAnimator anim3 = ObjectAnimator.ofFloat(text2_tv, "translationX", curTranslationX, -500f, curTranslationX);
            anim3.setDuration(3000);
            anim3.start();
            //将TextView在垂直方向上放大3倍再还原
            ObjectAnimator anim4 = ObjectAnimator.ofFloat(text2_tv, "scaleY", 1f, 3f, 1f);
            anim4.setDuration(5000);
            anim4.start();

    3.组合动画

    //让TextView先从屏幕外移动进屏幕,然后开始旋转360度,旋转的同时进行淡入淡出操作
            ObjectAnimator moveIn = ObjectAnimator.ofFloat(text3_tv, "translationX", -500f, 0f);
            ObjectAnimator rotate = ObjectAnimator.ofFloat(text3_tv, "rotation", 0f, 360f);
            ObjectAnimator fadeInOut = ObjectAnimator.ofFloat(text3_tv, "alpha", 1f, 0f, 1f);
            AnimatorSet animSet = new AnimatorSet();
            animSet.play(rotate).with(fadeInOut).after(moveIn);
            animSet.setDuration(5000);
            animSet.start();

     

  • 相关阅读:
    RT-thread内核之事件
    RT-thread内核之互斥量
    RT-thread内核之信号量
    RT-thread内核之进程间通信
    RT-thread内核之异常与中断
    RT-thread内核之IO设备管理系统
    RT-thread内核之小内存管理算法
    RT-thread内核之系统时钟
    RT-thread内核之定时器管理
    s19文件格式详解
  • 原文地址:https://www.cnblogs.com/chenzheng8975/p/10869333.html
Copyright © 2011-2022 走看看