zoukankan      html  css  js  c++  java
  • Animator动画XML实现

    在res下创建文件夹animator文件夹

    <?xml version="1.0" encoding="utf-8"?>
    <objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
                    android:propertyName="TranslationY"
                    android:duration="2000"
                    android:valueFrom="0.0"
                    android:valueTo="400.0"
                    android:interpolator="@android:anim/accelerate_interpolator"
                    android:valueType="floatType"
                    android:repeatCount="1"
                    android:repeatMode="reverse"
                    android:startOffset="2000"/>
    <?xml version="1.0" encoding="utf-8"?>
    <set xmlns:android="http://schemas.android.com/apk/res/android"
         android:ordering="together">
        <objectAnimator
                android:propertyName="x"
                android:duration="500"
                android:valueFrom="0"
                android:valueTo="400"
                android:valueType="floatType"/>
        <objectAnimator
                android:propertyName="y"
                android:duration="500"
                android:valueFrom="0"
                android:valueTo="300"
                android:valueType="floatType"/>
    </set>
    <?xml version="1.0" encoding="utf-8"?>
    <animator xmlns:android="http://schemas.android.com/apk/res/android"
              android:valueFrom="0"
              android:valueTo="300"
              android:duration="1000"
              android:valueType="intType"
              android:interpolator="@android:anim/bounce_interpolator"/>
        mTv = (TextView)findViewById(R.id.tv);
    
            findViewById(R.id.start_anim).setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    ObjectAnimator animator = (ObjectAnimator) AnimatorInflater.loadAnimator(MainActivity.this,
                            R.animator.object_animator);
                    animator.setTarget(mTv);
                    animator.start();
                }
            });
     mTv = (TextView)findViewById(R.id.tv);
    
            findViewById(R.id.start_anim).setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    AnimatorSet set = (AnimatorSet) AnimatorInflater.loadAnimator(MainActivity.this,
                            R.animator.set_animator);
                    set.setTarget(mTv);
                    set.start();
                }
            });
            mTv = (TextView)findViewById(R.id.tv);
            findViewById(R.id.start_anim).setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    ValueAnimator valueAnimator = (ValueAnimator) AnimatorInflater.loadAnimator(MainActivity.this,
                            R.animator.value_animator);
                    valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                        public void onAnimationUpdate(ValueAnimator animation) {
                            int offset = (Integer)animation.getAnimatedValue();
                            mTv.layout( offset,offset,mTv.getWidth()+offset,mTv.getHeight() + offset);
                        }
                    });
                    valueAnimator.start();
                }
            });
  • 相关阅读:
    理财课堂笔记第9天
    李筱懿的《先谋生,再谋爱》读后感
    bat想要写一个卸载软件的脚本,最后宣布失败[未完待续...]
    理财课堂日记第7天
    理财课堂日记第6天
    理财课堂日记第5天
    bat脚本登陆ftp服务器
    理财课堂笔记第4天
    理财课堂日记第3天
    理财课堂日记第2天
  • 原文地址:https://www.cnblogs.com/loaderman/p/10197094.html
Copyright © 2011-2022 走看看