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();
                }
            });
  • 相关阅读:
    想让进程后台运行,试试Linux的nohup命令,3分钟学会。
    面试官:你能说一下Redis的常见应用场景吗?
    面试被问MySQL 主从复制,怎么破?
    Spring Boot 解决跨域问题的 3 种方案!
    Kafka如果丢了消息,怎么处理的?
    惊呆,这样操作 Nginx 并发数就能达到3w?
    easyexcel 自动设置列宽(转)
    Ubuntu18.04自适应VMware调整桌面大小
    IDEA将maven项目打包时同时带上项目的maven依赖(转)
    python 定时框架APScheduler
  • 原文地址:https://www.cnblogs.com/loaderman/p/10197094.html
Copyright © 2011-2022 走看看