ANDROID_MARS学习笔记_S02_008_ANIMATION第二种使用方式:xml
一、简介

二、代码
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的更多相关文章
- ANDROID_MARS学习笔记_S02_007_Animation第一种使用方式:代码
一.简介 二.代码1.xml(1)activity_main.xml <?xml version="1.0" encoding="utf-8"?> ...
- JavaScript新手学习笔记3——三种排序方式(冒泡排序、插入排序、快速排序)
每种编程语言学到数组的时候,都会讲到排序算法,当时学C语言的时候,卡在排序算法.今天来总结一下javascript中如何实现三种排序算法. 1.冒泡排序(默认升序排列哦) 原理: 冒泡排序的原理,顾名 ...
- Stealth视频教程学习笔记(第二章)
Stealth视频教程学习笔记(第二章) 本文是对Unity官方视频教程Stealth的学习笔记.在此之前,本人整理了Stealth视频的英文字幕,并放到了优酷上.本文将分别对各个视频进行学习总结,提 ...
- .NET Remoting学习笔记(二)激活方式
目录 .NET Remoting学习笔记(一)概念 .NET Remoting学习笔记(二)激活方式 .NET Remoting学习笔记(三)信道 参考:百度百科 ♂风车车.Net 激活方式概念 在 ...
- 【转载】.NET Remoting学习笔记(二)激活方式
目录 .NET Remoting学习笔记(一)概念 .NET Remoting学习笔记(二)激活方式 .NET Remoting学习笔记(三)信道 参考:百度百科 ♂风车车.Net 激活方式概念 在访 ...
- 红帽学习笔记[RHCSA] 第二周
目录 红帽学习笔记[RHCSA]第二周 环境 第七课[网络配置相关] 在Vmware中添加网卡 将网卡添加到虚拟机上 关于网卡命名规则 配置网络 网络配置命令总结 更改hostname 关于SSH的一 ...
- Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第二十章:阴影贴图
原文:Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第二十章:阴影贴图 本章介绍一种在游戏和应用中,模拟动态阴影的基本阴影 ...
- Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第二十二章:四元数(QUATERNIONS)
原文:Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第二十二章:四元数(QUATERNIONS) 学习目标 回顾复数,以及 ...
- Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第二十一章:环境光遮蔽(AMBIENT OCCLUSION)
原文:Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第二十一章:环境光遮蔽(AMBIENT OCCLUSION) 学习目标 ...
随机推荐
- 配置WindowsLiveWriter,写cnblogs博客
转载:http://www.haogongju.net/art/2307587 引言 以前写博客一般都是联网在cnblogs上面写,不好的地方就是不联网就写不了,当然我们也可以先记录在word文件,等 ...
- 常用meta整理【转载】
< meta > 元素 概要 标签提供关于HTML文档的元数据.元数据不会显示在页面上,但是对于机器是可读的.它可用于浏览器(如何显示内容或重新加载页面),搜索引擎(关键词),或其他 we ...
- java 网络API访问 web 站点
package cn.magicdu.think.socket; import java.io.BufferedReader; import java.io.InputStreamReader; im ...
- 关于TouchEvent中出现异常:MessageQueue-JNI问题
Tag:MessageQueue-JNI Exception dispatching input event. Exception in MessageQueue callback: handleRe ...
- 04_HttpClient发送Https请求
[实例 带Cookie访问HTTPS类型的 建信基金 的某一页面)] /** * 创建一个可以访问Https类型URL的工具类,返回一个CloseableHttpClient实例 */ public ...
- UTF-8/UTF-16/UTF-32
UTF-8/UTF-16/UTF-32 一.UTF-8/UTF-16/UTF-32三者的区别 二.BOM的检测与删除 1.用VIM去除<feff>,即 U+FEFF.注意:这是一个字符,而 ...
- 九度OJ 1104 整除问题
题目地址:http://ac.jobdu.com/problem.php?pid=1104 题目描述: 给定n,a求最大的k,使n!可以被a^k整除但不能被a^(k+1)整除. 输入: 两个整数n(2 ...
- OpenJudge 2786 Pell数列
1.链接地址: http://bailian.openjudge.cn/practice/2786 2.题目: 总Time Limit: 3000ms Memory Limit: 65536kB De ...
- dd命令测试linux磁盘读写速度
1.先熟悉两个特殊的设备: (1)/dev/null:回收站.无底洞. (2)/dev/zero:产生字符. 2.测试磁盘写能力 time dd if=/dev/zero of=/t ...
- C语言使用中的细节问题总结
1.在使用bool关键字时,出现"error:'bool' undeclared(first use in this function)"的错误,原因为C语言本身是没有bool关键 ...