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) 学习目标 ...
随机推荐
- 使用MVCJqGrid的心得
最近公司网站进行升级,项目要用.net mvc,mysql和轻量级orm框架dapper.由于美工页面出不来啊,让我先写简单写写后台的列表,同事说用MvcJqGrid,也得到了架构的同意. 可是不得不 ...
- JDBC向oracle插入数据
public static void main(String[] args) throws SQLException { 2 3 4 String driver="oracle.jdbc.d ...
- 解决Redis Cluster模式下的排序问题
通常的redis排序我们可以这么做: 比如按商品价格排序:sort goods_id_set by p_*_price 这样在非集群模式下是没问题的,但如果在集群模式下,就会报错: 说是在集群模式下不 ...
- iOS对textField进行字符长度限制的办法
在项目开发过程中,遇到这么一个需求,编辑标签时,输入的最大长度需要限制为24个字节. 查阅了一些材料,并参考了之前项目的相关处理办法,今天在这里总结一下解决方案. 1.写一个截取字符串的方法,将超长的 ...
- javascript RegExp类型 学习小记
在js里面,可以有两种方法来定义正则表达式,第一种是通过字变量的形式,第二种则是通过构造函数的形式: 1 字变量形式,格式是长这样子的 var expression = /pattern/flag p ...
- 393. UTF-8 Validation
393. UTF-8 Validation 这个题很明确,刚开始我以为只能是一个utf,长度大于5的都判断为false,后来才明白题意. 有个小trick,就是长度大于1的时候,判断第一个数字开始1的 ...
- vbscript multiple line syntax
Vbscript 如何将输出内容换行? ' VbCrLf represetns Carriage return–linefeed combination, for more information s ...
- 事件兼容IE
addEvent:function(target, functionref, tasktype) { if (target.addEventListener) target.addEventListe ...
- GDI+ 如何将图片绘制成圆形的图片
大概意思就是不生成新的图片,而是将图片转换为圆形图片. 实现代码如下: private Image CutEllipse(Image img, Rectangle rec, Size size) { ...
- memcached全面剖析--4
memcached的分布式算法 memcached的分布式 正如第1次中介绍的那样, memcached虽然称为“分布式”缓存服务器,但服务器端并没有“分布式”功能. 服务器端仅包括 第2次. 第 ...