zoukankan      html  css  js  c++  java
  • 属性动画

    这是属性动画的干货,这是单一动画,

    222222
    
    textview = (TextView) findViewById(R.id.textview);
            textview.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Toast.makeText(getApplication(), "你点击我了", Toast.LENGTH_SHORT).show();
                }
            });
    //ObjectAnimator 是继承自ValueAnimator的,ValueAnimator比较少用
    // ObjectAnimator animator = ObjectAnimator.ofFloat(textview,"alpha",1f,0f,1f);//alpha 透明变换 // ObjectAnimator animator = ObjectAnimator.ofFloat(textview,"rotation",0f,360f,);//rotation 360°旋转 float curTranslationY = textview.getTranslationY(); ObjectAnimator animator = ObjectAnimator.ofFloat(textview, "translationY", curTranslationY, 500f); // translationX 水平移动,负值向左,正直向右 translationY 垂直移动,正值向下,负值向上 //ObjectAnimator animator = ObjectAnimator.ofFloat(textview,"scaleX",1f,6f,1f); //scaleY 垂直缩放 scaleX水平缩放  animator.setDuration(3000);//动作完成时间
    
        //动画播放监听
           /* animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                @Override
                public void onAnimationUpdate(ValueAnimator valueAnimator) {
                    float currentValue = (float) valueAnimator.getAnimatedValue();
                    Log.d("TAG", "cuurent value is " + currentValue);
                }
            });*/
            // animator.setStartDelay(5000);//延迟执行
            // animator.setRepeatCount(1);//循环次数
            // animator.setRepeatMode(ValueAnimator.REVERSE);//ValueAnimator.REVERSE倒序播放  ValueAnimator.RESTART重新播放
            animator.start();

     下面再贴上组合动画,组合动画就是生成几个动画之后,把他们按照想要的顺序组合起来播放,靠的是 AnimatorSet

        ObjectAnimator moveIn = ObjectAnimator.ofFloat(textview, "translationX", -500f, 0f);
            ObjectAnimator rotate = ObjectAnimator.ofFloat(textview, "rotation", 0f, 360f);
            ObjectAnimator fadeInOut = ObjectAnimator.ofFloat(textview, "alpha", 1f, 0f, 1f);
            AnimatorSet animSet = new AnimatorSet();
            animSet.play(rotate).with(fadeInOut).after(moveIn);//play是播放,with是同时进行,after是在某个动画执行完之后
            animSet.setDuration(5000);
            animSet.start();
  • 相关阅读:
    LR回放webservice脚本报错------------mmdrv.exe应用程序错误(未解决)
    转载:shell中#*,##*,#*,##*,% *,%% *的含义及用法
    转载:Linux命令经典面试题:统计文件中出现次数最多的前10个单词
    Python---求100以内的质数
    用shell编写小九九乘法表程序
    python中遇到的问题:IndentationError: unexpected indent
    关于redis的持久化策略
    关于equals和hashcode问题
    Spring源码窥探之:Spring AOP初步使用
    Spring源码窥探之:@Value
  • 原文地址:https://www.cnblogs.com/laoyimou/p/7832661.html
Copyright © 2011-2022 走看看