一:显示隐藏动画

在res目录下创建一个anim目录,然后在里面创建一个alpha.xml文件

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false"
>
<alpha
android:fromAlpha="1.0"
android:toAlpha="0"
android:duration="5000"
>
</alpha>
</set>

在显示的页面添加一张图片,然后在MainActivity.java文件,获得需要进行动画的对象,获得动画东西那个,将需要的对象添加动画的对象到动画的方法

package cn.szy.com;

import android.app.Activity;
import android.os.Bundle;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView; public class MainActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main); Animation animation = AnimationUtils.loadAnimation(this, R.anim.alpha);
animation.setFillAfter(true);
ImageView imageview = (ImageView) this.findViewById(R.id.imageView1);
imageview.startAnimation(animation);
}
}

二:移动动画

在res目录下创建一个anim目录,然后在里面创建一个translate.xml文件,然后在动画里面获取了之后加载进去就行了

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

三:旋转动画

在res目录下创建一个anim目录,然后在里面创建一个rotate.xml文件,然后在动画里面获取了之后加载进去就行了

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false"
>
<rotate
android:fromDegrees="0" android:toDegrees="180"
android:pivotX="50%"
android:pivotY="50%"
android:duration="5000"
>
</rotate>
</set>

四:放大动画

在res目录下创建一个anim目录,然后在里面创建一个scale.xml文件,然后在动画里面获取了之后加载进去就行了

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false" >
<scale
android:fromXScale="1.0"
android:fromYScale="1.0"
android:toXScale="5.0"
android:toYScale="5.0"
android:pivotX="50%"
android:pivotY="50%"
android:duration="5000"
/>
</set>

五:集合动画,将多个动画的动作写到一个文件中,会按顺序和时间进行调用,就能够实现一些复杂的动画

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false"
>
<translate
android:fromXDelta="0"
android:fromYDelta="0"
android:toXDelta="100"
android:toYDelta="100"
android:duration="5000"
>
</translate>
<scale
android:fromXScale="1.0"
android:fromYScale="1.0"
android:toXScale="5.0"
android:toYScale="5.0"
android:pivotX="50%"
android:pivotY="50%"
android:duration="5000"
/>
<alpha
android:fromAlpha="1.0"
android:toAlpha="0"
android:duration="5000"
/>
</set>

Java-Android 之动画的实现的更多相关文章

  1. 79.Android之动画基础

    转载:http://a.codekk.com/detail/Android/lightSky/%E5%85%AC%E5%85%B1%E6%8A%80%E6%9C%AF%E7%82%B9%E4%B9%8 ...

  2. Android滑动动画ViewFlipper和视频播放VideoView的使用

    Android滑动动画,可以用ViewPager或者ViewFlipper实现. ViewPager自带触摸滑动功能,结合Fragment使用很好,来自补充组件android-support-v4.j ...

  3. Android的动画

    一.动画类型 Android的animation由四种类型组成:alpha.scale.translate.rotate XML配置文件中 alpha 渐变透明度动画效果 scale 渐变尺寸伸缩动画 ...

  4. Android View动画

    Animation TypeEvaluator View的animate方法 ValueAnimator ObjectAnimator AnimatorSet 使用xml来创建动画 animation ...

  5. Android Animation动画(很详细)

    Android Animation   Contents: Animations Tween Animations AnimationSet Interpolator Frame-By-Frame A ...

  6. Android Animations动画使用详解

    一.动画类型 Android的animation由四种类型组成:alpha.scale.translate.rotate XML配置文件中 alpha 渐变透明度动画效果 scale 渐变尺寸伸缩动画 ...

  7. Android 开机动画源码分析

    Android系统在启动SystemServer进程时,通过两个阶段来启动系统所有服务,在第一阶段启动本地服务,如SurfaceFlinger,SensorService等,在第二阶段则启动一系列的J ...

  8. Java&Android反编工具打包

    Java&Android反编工具: 1.Eclipse反编插件:安装到Eclipse后,可以简要的查看jar包中的*.class; 2.DoAPK:反编*.apk为smali和一些资源文件,可 ...

  9. android Animation动画的xml使用

    在Android应用程序,使用动画效果,能带给用户更好的感觉,做动画能够通过XML或Android代码来实现. Animation动画效果的实现能够通过两种方式进行实现,一种是tweened anim ...

  10. android 属性动画

    一直再追郭霖的博客和imooc上的一些新的视频,最近有讲到属性动画. 以下内容为博客学习以及imooc上视频资料的学习笔记: 在3.0之前比较常见的动画为tween动画和frame动画: tween动 ...

随机推荐

  1. Javascript自动换图片

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  2. Linux kernel 内存损坏漏洞

    漏洞名称: Linux kernel 内存损坏漏洞 CNNVD编号: CNNVD-201310-143 发布时间: 2013-10-11 更新时间: 2013-10-11 危害等级: 中危   漏洞类 ...

  3. DevExpress控件学习总结 z

    1.Navigation & Layout 1.1 Bar Manager 如果想在窗体或用户控件(user control)上添加工具条(bars)或弹出菜单(popup menus),我们 ...

  4. C# Sending data using GET or POST ZZ

    In this short article, I'll show you how to send data to a website from a C# application using GET o ...

  5. C# config配置文件 自定义节点读取

    主要使用:ConfigurationSection IConfigurationSectionHandler已被否决 http://technet.microsoft.com/zh-cn/librar ...

  6. HTML5与CSS3权威指南.pdf6

    第11章 获取地理位置信息 HTML5为window.navigator对象新增了一个geolocation属性 取得当前地理位置 void getCurrentPosition(onSuccess, ...

  7. ASP.NET中设置一个定时器来定时更新 转

    asp.net 定时器 比较少用,  中国红木网这是一个相当实用的功能,有了RSS博客镜像,就不需要在多处同时发布博客日志了.比如你同时在新浪上有自己的博客,又同时有自己的个人博客站点,那么你只需要在 ...

  8. Java中重载和重写的区别

    重载 overloading 1) 方法重载是让类以统一的方式处理不同类型数据的一种手段.多个同名函数同时存在,具有不同的参数个数/类型.重载是一个类中多态性的一种表现. 2) Java的方法重载,就 ...

  9. vimrc语法

    前言 工欲善其事,必先利其器.一个programmer必然要先有一个好的editor.vim就是一个十分强大的编辑器.它的强大之处,在于其个性化和可定制.学习vim,就像学习Linux,学习perl, ...

  10. Installing Windows Identity Foundation on Windows 8 - The Certificate for the signer of the message is invalid or not found.

    Just a very quick note here, in case you’re struggling to get Windows Identity Foundation installed ...