zoukankan      html  css  js  c++  java
  • android位移动画的两种实现方式

    在android开发,我们会常常使用到位移动画,普通情况下位移动画有两种实现方式。一种是直接通过java代码去实现,第二种是通过配置文件实现动画,以下是两种动画的基本是用法:

    纯Java代码实现:

    //创建渐变动画 
    		Animation animation = new TranslateAnimation(0, 0, 300, 300);
    		animation.setDuration(1500);
    		animation.setRepeatCount(1);//动画的反复次数
    		animation.setFillAfter(true);//设置为true,动画转化结束后被应用
    		imageView1.startAnimation(animation);//開始动画

    通过配置文件实现:

    1、首先要在res文件夹下建立一个anim文件。在anim建立一个alpha1.xml文件例如以下:

    <?

    xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <translate android:duration="1500" android:fromXDelta="0" android:fromYDelta="0" android:toXDelta="200" android:toYDelta="300" android:repeatCount="3" android:interpolator="@android:anim/cycle_interpolator" android:repeatMode="reverse" /> </set>


    2、载入动画

    Animation animation = AnimationUtils.loadAnimation(this, R.anim.translate);
    		imageView1.startAnimation(animation);//開始动画
    案例下载地址:http://download.csdn.net/detail/u013043346/9374204

  • 相关阅读:
    jenkins的目录介绍
    Docker 配置国内镜像加速器
    jquery----TreeTable
    java web----jsp语法
    Spring MVC----@ResponseBody注解(json)
    jquery----datatables
    java web----jsp自定义标签
    js----单步调试
    jquery----查找标签
    jquery----icheck插件
  • 原文地址:https://www.cnblogs.com/tlnshuju/p/7358903.html
Copyright © 2011-2022 走看看