一、简介

  

二、代码
1.res\anim下的xml
(1)alpha.xml.xml

 <?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator">
<alpha
android:fromAlpha="1.0"
android:toAlpha="0.0"
android:startOffset="500"
android:duration="1000"/>
</set>

(2)rotate.xml

 <?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator">
<rotate
android:fromDegrees="0"
android:toDegrees="720"
android:pivotX="50%"
android:pivotY="100%"
android:duration="3000"/>
</set>

(3)scale.xml

 <?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator">
<scale
android:fromXScale="1.0"
android:toXScale="0.0"
android:fromYScale="1.0"
android:toYScale="0.0"
android:pivotX="50%"
android:pivotY="50%"
android:duration="2000"/> </set>

(4)tranlate.xml

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

2.java
(1)MainActivity.java

 package com.animation2;

 import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.ImageView; public class MainActivity extends Activity { private ImageView imageView = null;
private Button rotateButton = null;
private Button scaleButton = null;
private Button alphaButton = null;
private Button translateButton = null; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); imageView = (ImageView) findViewById(R.id.imageViewId); rotateButton = (Button) findViewById(R.id.rotateButtonId);
rotateButton.setOnClickListener(new RotateButtonListener()); scaleButton = (Button) findViewById(R.id.scaleButtonId);
scaleButton.setOnClickListener(new ScaleButtonListener()); alphaButton = (Button) findViewById(R.id.alphaButtonId);
alphaButton.setOnClickListener(new AlphaButtonListener()); translateButton = (Button) findViewById(R.id.translateButtonId);
translateButton.setOnClickListener(new TranslateButtonListener());
} class TranslateButtonListener implements OnClickListener {
@Override
public void onClick(View v) {
Animation animation = AnimationUtils.loadAnimation(MainActivity.this, R.anim.tranlate);
imageView.startAnimation(animation);
}
} class AlphaButtonListener implements OnClickListener {
@Override
public void onClick(View v) {
Animation animation = AnimationUtils.loadAnimation(MainActivity.this, R.anim.alpha);
imageView.startAnimation(animation);
}
} class ScaleButtonListener implements OnClickListener {
@Override
public void onClick(View v) {
Animation animation = AnimationUtils.loadAnimation(MainActivity.this, R.anim.scale);
imageView.startAnimation(animation);
}
} class RotateButtonListener implements OnClickListener {
@Override
public void onClick(View v) {
Animation animation = AnimationUtils.loadAnimation(MainActivity.this, R.anim.rotate);
imageView.startAnimation(animation);
}
}
}

ANDROID_MARS学习笔记_S02_008_ANIMATION第二种使用方式:xml的更多相关文章

  1. ANDROID_MARS学习笔记_S02_007_Animation第一种使用方式:代码

    一.简介 二.代码1.xml(1)activity_main.xml <?xml version="1.0" encoding="utf-8"?> ...

  2. JavaScript新手学习笔记3——三种排序方式(冒泡排序、插入排序、快速排序)

    每种编程语言学到数组的时候,都会讲到排序算法,当时学C语言的时候,卡在排序算法.今天来总结一下javascript中如何实现三种排序算法. 1.冒泡排序(默认升序排列哦) 原理: 冒泡排序的原理,顾名 ...

  3. Stealth视频教程学习笔记(第二章)

    Stealth视频教程学习笔记(第二章) 本文是对Unity官方视频教程Stealth的学习笔记.在此之前,本人整理了Stealth视频的英文字幕,并放到了优酷上.本文将分别对各个视频进行学习总结,提 ...

  4. .NET Remoting学习笔记(二)激活方式

    目录 .NET Remoting学习笔记(一)概念 .NET Remoting学习笔记(二)激活方式 .NET Remoting学习笔记(三)信道 参考:百度百科  ♂风车车.Net 激活方式概念 在 ...

  5. 【转载】.NET Remoting学习笔记(二)激活方式

    目录 .NET Remoting学习笔记(一)概念 .NET Remoting学习笔记(二)激活方式 .NET Remoting学习笔记(三)信道 参考:百度百科 ♂风车车.Net 激活方式概念 在访 ...

  6. 红帽学习笔记[RHCSA] 第二周

    目录 红帽学习笔记[RHCSA]第二周 环境 第七课[网络配置相关] 在Vmware中添加网卡 将网卡添加到虚拟机上 关于网卡命名规则 配置网络 网络配置命令总结 更改hostname 关于SSH的一 ...

  7. Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第二十章:阴影贴图

    原文:Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第二十章:阴影贴图 本章介绍一种在游戏和应用中,模拟动态阴影的基本阴影 ...

  8. Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第二十二章:四元数(QUATERNIONS)

    原文:Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第二十二章:四元数(QUATERNIONS) 学习目标 回顾复数,以及 ...

  9. Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第二十一章:环境光遮蔽(AMBIENT OCCLUSION)

    原文:Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第二十一章:环境光遮蔽(AMBIENT OCCLUSION) 学习目标 ...

随机推荐

  1. js中的null与undefined

    null undefined

  2. Android数据存储方式之SharedPreferences

    Android平台给我们提供了一个SharedPreferences类,它是一个轻量级的存储类,特别适合用于保存软件配置参数.使用SharedPreferences保存数据,其背后是用xml文件存放数 ...

  3. 用PHP操作http中Etag、lastModified和Expires标签

    http://blog.hehehehehe.cn/a/10994.htm 客户端通过浏览器发出第一次请求某一个URL时,根据 HTTP 协议的规定,浏览器会向服务器传送报头(Http Request ...

  4. python学习第二天:数字与字符串转换及逻辑值

    1.数字与字符串的转化     #1.数字转字符,使用格式化字符串:         *1.demo = ‘%d’  %  source         *2.%d整型:%f 浮点型 :%e科学计数 ...

  5. LaTeX中用BibTex管理参考文献

    BibTeX 是一种用来规范参考文献列表的一种文献管理软件,定义了一种比较通用的管理文献的格式, 用于协调LaTeX的参考文献处理. BibTeX 使用数据库的的方式来管理参考文献. BibTeX 文 ...

  6. iOS自学之NSOperation、NSOperationQueue、Background

    iOS中多线程编程主要分为NSThread.NSOperation和GCD,今天主要记录下自己在学习NSOperation中的点滴-如有不对的地方帮忙指出下,PS:人生第一次写blog,各位看官请轻虐 ...

  7. 【html】【13】特效篇--下拉导航

    html代码: <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" ...

  8. OC1_数组创建

    // // main.m // OC1_数组创建 // // Created by zhangxueming on 15/6/11. // Copyright (c) 2015年 zhangxuemi ...

  9. Nwjs从入门到精通 菜鸟实践笔记【1】

    最近公司有想使用Nw来开发浏览器的想法,自己一直学的PHP,在网上并没有找到太多的相关资料,所以,就自己摸索着撸一条自学笔记: 当然呢,这里记录的都是我自己学习中遇到的问题,以及收获,希望通过自己的分 ...

  10. 【转】MSSQL获取指定表的列名信息,描述,数据类型,长度

    /* --作用:根据特定的表名查询出字段,以及描述,数据类型,长度,精度,是否自增,是否为空等信息 --作者:wonder QQ:37036846 QQ群:.NET顶级精英群 ID:124766907 ...