• 属性动画


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

    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();
  • 相关阅读:
    数组_leetcode283
    数组_leetcode438
    数组_leetcode215
    数组_leetcode167
    数组_leetcode209
    数组_leetcode88
    数组_leetcode80
    数组_leetcode76
    数组_leetcode75
    数组_leetcode27
  • 原文地址:https://www.cnblogs.com/laoyimou/p/7832661.html
Copyright © 2020-2023  润新知