zoukankan      html  css  js  c++  java
  • View Animation 视图动画全解

    先看一下图:

    一 res/anim/目录下新建xml文件

    1.alpha (透明度)标签:va_alpha.xml

    <?xml version="1.0" encoding="utf-8"?>
    <alpha xmlns:android="http://schemas.android.com/apk/res/android"
           android:duration="4000"
           android:fromAlpha="0.0"
           android:toAlpha="1.0">
    </alpha>


    2.scale(缩放) 标签:va_scale.xml

    <?xml version="1.0" encoding="utf-8"?>
    
    <scale xmlns:android="http://schemas.android.com/apk/res/android"
           android:duration="1000"
           android:fromXScale="1.0"
           android:fromYScale="1.0"
           android:pivotX="0%"
           android:pivotY="0%"
           android:toXScale="0.5"
           android:toYScale="0.5"
    
           android:fillAfter="true"
           android:repeatCount="1"
           android:startOffset="1000"
    
        />
    

    3.rotate(旋转)标签:va_rotate.xml

    <?xml version="1.0" encoding="utf-8"?>
    <rotate xmlns:android="http://schemas.android.com/apk/res/android"
            android:duration="1000"
            android:pivotX="50%"
            android:pivotY="0%"
            android:fromDegrees="-40"
            android:toDegrees="40"
            android:interpolator="@android:anim/accelerate_decelerate_interpolator"
    
            android:repeatMode="reverse"
            android:repeatCount="-1"
        />
    

    4.translation(移动)标签:va_translation.xml

    <?xml version="1.0" encoding="utf-8"?>
    
    <translate xmlns:android="http://schemas.android.com/apk/res/android"
               android:fromXDelta="0%"
               android:fromYDelta="0"
               android:toXDelta="100%p"
               android:toYDelta="0"
               android:duration="2000"
        />
    

    5.set(动画集)标签:va_set.xml

    <?xml version="1.0" encoding="utf-8"?>
    <set xmlns:android="http://schemas.android.com/apk/res/android"
         android:duration="1000"
         android:fillAfter="true">
    
        <scale xmlns:android="http://schemas.android.com/apk/res/android"
               android:fromXScale="1.0"
               android:fromYScale="1.0"
               android:pivotX="0%"
               android:pivotY="0%"
               android:toXScale="0.5"
               android:toYScale="0.5"/>
    
        <rotate xmlns:android="http://schemas.android.com/apk/res/android"
                android:fromDegrees="0"
                android:pivotX="50%"
                android:pivotY="50%"
                android:toDegrees="360"/>
    </set>

    二   res/layout/布局文件添加

    <ImageView
        android:id="@+id/test_iv"
        android:layout_gravity="center"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/rotate"/>

    三  代码使用:

    //mIvTest.startAnimation(AnimationUtils.loadAnimation(MainActivity.this, R.anim.va_alpha));
    //mIvTest.startAnimation(AnimationUtils.loadAnimation(MainActivity.this, R.anim.va_scale));
    //mIvTest.startAnimation(AnimationUtils.loadAnimation(MainActivity.this, R.anim.va_translate));
     mIvTest.startAnimation(AnimationUtils.loadAnimation(MainActivity.this, R.anim.va_rotate));
    //mIvTest.startAnimation(AnimationUtils.loadAnimation(MainActivity.this, R.anim.va_set));


    效果:依次:alpha、scalerotate、translation、set



  • 相关阅读:
    framework 3 ,4
    C# 线程
    ReportingService错误:配置参数 SharePointIntegrated 被设置为 True,但无法加载 Share Point 对象模型
    C# 打印 word pdf PrintOut方法
    C# 多线程控制控件实例(例程简单,注释详细)
    Windchill MethodServer启动后自动关闭
    Press C#使用指定打印机打印Word,Excel等Office文件和打印PDF文件的代码 (转)
    ExtJs入门
    The transaction log for database 'wcadmin' is full. To find out why space in the log cannot be reused, see the log_reuse_wait_desc column in sys.datab
    JS+调用word打印功能实现在Webfrom客户端
  • 原文地址:https://www.cnblogs.com/toly-top/p/9782040.html
Copyright © 2011-2022 走看看