zoukankan      html  css  js  c++  java
  • 补间动画实现(tween)

    1.补间动画的概念:

    补间动画:仅仅须要开发人员设置好动画的開始与结束的关键帧 中间帧有喜用计算机补齐。

    2.种类:分为4种: ①alpha 透明度 ②alpha 透明度 ③translate 位置移动 ④rotate 旋转动画

    3.实现

      ① Java代码实现

       1)alpha 透明度 AlphaAnimation
       设置动画的透明度開始与结束 设置持续的时间。

       2.scale 比例缩放 ScaleAnimation
        设置缩放參照的中心轴(pivotyX,pivotyY)设置缩放開始的比例(x,y),结束的比例(x,y),

       3)translate 位置移动
           TranslateAnimation 设置动画的透明度開始(x,y)与结束(x,y) 设置持续的时间。

        4).rotate 旋转动画
         RotateAnimation 设置动画開始旋转的角度,结束时旋转的角度,并指定动画的持续时间,设置旋转的中心轴(pivotyX,pivotyY)
        5).综合应用:AnimationSet,set.addAnimation(a);

        ② XMl文件实现 结合代码 res/anim

        1).alpha 透明度<alpja></alpja>

        2).scale 比例缩放 <scale></scale>

        3).translate 位置移动<translate></translate>

        4).rotate 旋转动画 <rotate></rotate>

         综合应用:<set></set>  辅助类  AnimationUtils.loadAnimation(context, id);

    4.案例:

    1)创建xml文件进行4种方式的填写

        

    2)以rotate方式为例,能够:

    <?xml version="1.0" encoding="utf-8"?>
    <rotate xmlns:android="http://schemas.android.com/apk/res/android"
            android:fromDegrees="0" 
            android:toDegrees="1800"
            android:pivotX="50%"
            android:pivotY="50%"
            android:duration="3000"
            android:fillAfter="true"></rotate>
    

    3)进行界面上的动画设置:

    public void clickRotate(View v) {
    		 rotateXml();
    		// rotateJava();
    
    	}
    
    	private void rotateXml() {
    		// 1.获取动画对象
    		Animation animation = AnimationUtils.loadAnimation(this,
    				R.anim.rotate_tween);
    		// 2.设置动画效果
    		imageView.setAnimation(animation);
    	}
    
    	public void rotateJava() {
    		// 1.创建动画的透明度对象
    		RotateAnimation rotateAnimation = new RotateAnimation(0, 1800, 0, 50);
    		// 2.为透明度动画对象设置值
    		rotateAnimation.setDuration(2000);
    		rotateAnimation.setFillAfter(true);
    		// 3.设置控件的动画
    		imageView.setAnimation(rotateAnimation);
    
    	}
    

    4)动画效果:

  • 相关阅读:
    【YbtOJ#20238】最优路线
    【洛谷P3247】最小公倍数
    【洛谷P3261】城池攻占
    【YbtOJ#20236】红点蓝点
    【YbtOJ#20235】公共序列
    Wing IDE 4.1使用笔记一修正一下框框字体显示不了中文
    飘逸的python
    The 12th tip of DB Query Analyzer, powerful in text file process
    PHP网站如何解决大流量与高并发的问题
    【python】利用sftp及rsa密匙实现远程拷贝文件
  • 原文地址:https://www.cnblogs.com/mfrbuaa/p/4083104.html
Copyright © 2011-2022 走看看