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();
                }
            });
  • 相关阅读:
    转 进程与线程的区别与联系
    DoEvents的应用及注意事项
    转:error LNK2001 错误
    基于UDP的简单的聊天程序
    VB提示:文件未找到:'c:\windows\sytem32\ieframe.dll\1'的解决方法
    VB PopupMenu方法
    转 vb中SetWindowsHookEx详细用法及举例
    Python批量转换txt文件为excel文件
    excel自动筛选后分别复制粘贴到新文件的解决办法
    文本编辑
  • 原文地址:https://www.cnblogs.com/loaderman/p/10197094.html
Copyright © 2011-2022 走看看