Java-Android 之动画的实现
一:显示隐藏动画
在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 之动画的实现的更多相关文章
- 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 ...
- Android滑动动画ViewFlipper和视频播放VideoView的使用
Android滑动动画,可以用ViewPager或者ViewFlipper实现. ViewPager自带触摸滑动功能,结合Fragment使用很好,来自补充组件android-support-v4.j ...
- Android的动画
一.动画类型 Android的animation由四种类型组成:alpha.scale.translate.rotate XML配置文件中 alpha 渐变透明度动画效果 scale 渐变尺寸伸缩动画 ...
- Android View动画
Animation TypeEvaluator View的animate方法 ValueAnimator ObjectAnimator AnimatorSet 使用xml来创建动画 animation ...
- Android Animation动画(很详细)
Android Animation Contents: Animations Tween Animations AnimationSet Interpolator Frame-By-Frame A ...
- Android Animations动画使用详解
一.动画类型 Android的animation由四种类型组成:alpha.scale.translate.rotate XML配置文件中 alpha 渐变透明度动画效果 scale 渐变尺寸伸缩动画 ...
- Android 开机动画源码分析
Android系统在启动SystemServer进程时,通过两个阶段来启动系统所有服务,在第一阶段启动本地服务,如SurfaceFlinger,SensorService等,在第二阶段则启动一系列的J ...
- Java&Android反编工具打包
Java&Android反编工具: 1.Eclipse反编插件:安装到Eclipse后,可以简要的查看jar包中的*.class; 2.DoAPK:反编*.apk为smali和一些资源文件,可 ...
- android Animation动画的xml使用
在Android应用程序,使用动画效果,能带给用户更好的感觉,做动画能够通过XML或Android代码来实现. Animation动画效果的实现能够通过两种方式进行实现,一种是tweened anim ...
- android 属性动画
一直再追郭霖的博客和imooc上的一些新的视频,最近有讲到属性动画. 以下内容为博客学习以及imooc上视频资料的学习笔记: 在3.0之前比较常见的动画为tween动画和frame动画: tween动 ...
随机推荐
- AT&T汇编中系统调用和C函数调用的使用
我的博客:www.while0.com 区别: 系统调用的参数存储在寄存器中,函数调用的则存储在堆栈中. 系统调用使用中断方式,函数调用使用call指令 相同之处: 都有返回值和输入值 返回值都存储在 ...
- Properties vs. Attributes
http://blogs.msdn.com/b/ericlippert/archive/2009/02/02/properties-vs-attributes.aspx Here is yet ano ...
- ♫【CSS】命名颜色
color: aqua; 每个浏览器都支持一套它能识别且能正确渲染的命名颜色.这些颜色包括: aqua 浅绿色 #00ffffblack 黑色 #000000blue 蓝色 #0000fffuchsi ...
- 如何在Azure环境里做好信息传递可扩展性经验分享
作者 王枫 发布于2014年5月15日 综述 本文介绍建立一个在Azure上使用Azure服务总线, 高吞吐量短信平台的必要步骤.在这篇文章中提出的解决方案是在响应由客户的具体要求,建立一个基于Win ...
- Apache Log4j使用实例
Apache Log4j使用实例 原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任. Blog: 1.Logger类 通过Logger类的静 ...
- uva 10047 the monocyle (四维bfs)
算法指南白书 维护一个四维数组,走一步更新一步 #include<cstdio> #include<cstring> #include<queue> #includ ...
- 2008---2009学年(A)B)第1学期《中国近代史纲要》课程考核试卷
湖南人文科技学院公共课 2008---2009学年第1学期<中国近代史纲要>课程考核试卷(A) 考核方式: (闭卷) ...
- webstorage调查资料汇总
在调查webstorage的过程中,一步一步了解了各种缓存或存储机制,local storage本地存储,application cache离线应用存储,http cache是http本身自带的缓存机 ...
- Sicily1317-Sudoku-位运算暴搜
最终代码地址:https://github.com/laiy/Datastructure-Algorithm/blob/master/sicily/1317.c 这题博主刷了1天,不是为了做出来,AC ...
- Android基础知识回顾