千家信息网

Android中Animation资源有哪些

发表于:2026-11-01 作者:千家信息网编辑
千家信息网最后更新 2026年11月01日,本篇内容介绍了"Android中Animation资源有哪些"的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有
千家信息网最后更新 2026年11月01日Android中Animation资源有哪些

本篇内容介绍了"Android中Animation资源有哪些"的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!

SDK中的示例程序App->Activity->Animation演示了切换Activity时的动画效果。提供了两种动画效果,一种是Fade In渐变,后出现的Activity由浅入深逐渐显示;另一种是Zoom放大效果,后出现的Activity由小及大逐渐显示。

Android 中 Animation 资源可以分为两种:

Tween Animation 对单个图像进行各种变换(缩放,平移,旋转等)来实现动画。

Frame Animation 由一组图像顺序显示显示动画。

Animation 中使用的是Tween Animation,使用的资源为R.anim.fade、R.anim.hold、R.anim.zoom_enter、R.anim.zoom_exit。

其中R.anim.fade、R.anim.zoom_enter分别为Fade In 和 Zoom动画资源。其定义为:

fade.xml

zoom_center.xml

      

tween animation 资源定义的格式如下:

                         …         

为其它animation类型,,和或其它的容器。

android:interpolator 为Interpolator资源ID,Interpolator定义了动画的变化速率,动画的各帧的显示可以加速,减速,重复显示。

android:shareInterpolator 如果想为中的各个子动画定义共享interpolator,shareInterpolator 则设为true。

定义Fade in 、Fade out 动画,其对应的Android类AlphaAnimation,参数由fromAlpha,toAlpha定义。

定义缩放动画,其对应的Android类为ScaleAnimation,参数由fromXScale、toXScale、 fromYScale、toYScale、pivotX、pivotY定义,pivotX、pivotY定义了缩放时的中心。

定义平移动画,其对应的Android类为TranslateAnimation,参数由fromXDelta、toXDelta、fromYDelta、toYDelta定义。

定义选择动画,其对应的Android类RotateAnimation,参数由fromDegrees、toDegrees、pivotX、pivotY, pivotX、pivotY定义选择中心。

Animation中的Fade In和Zoom In按钮的事件处理代码:

private OnClickListener mFadeListener = new OnClickListener() {     public void onClick(View v) {     // Request the next activity transition (here starting a new one).     startActivity(new Intent(Animation.this, Controls1.class));     // Supply a custom animation.  This one will just fade the new     // activity on top.  Note that we need to also supply an animation     // (here just doing nothing for the same amount of time) for the     // old activity to prevent it from going away too soon.     overridePendingTransition(R.anim.fade, R.anim.hold);     }    };   private OnClickListener mZoomListener = new OnClickListener() {     public void onClick(View v) {     // Request the next activity transition (here starting a new one).     startActivity(new Intent(Animation.this, Controls1.class));     // This is a more complicated animation, involving transformations     // on both this (exit) and the new (enter) activity.  Note how for     // the duration of the animation we force the exiting activity     // to be Z-ordered on top (even though it really isn't) to achieve     // the effect we want.     overridePendingTransition(R.anim.zoom_enter, R.anim.zoom_exit);     }    };

从代码可以看到Activity Animation到其它Activity Controls1 切换的动画使用overridePendingTransition 来定义,函数overridePendingTransition(int enterAnim, int exitAnim) 必须定义在StartActivity(Intent) 或是 Activity.finish()之后来定义两个Activity切换时的动画,enterAnim 为新Activity出现时动画效果,exitAnim则定义了当前Activity退出时动画效果。

"Android中Animation资源有哪些"的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注网站,小编将为大家输出更多高质量的实用文章!

动画 资源 效果 参数 切换 代码 内容 更多 知识 平移 选择 实用 学有所成 接下来 由浅入深 两个 个子 事件 函数 单个 数据库的安全要保护哪些东西 数据库安全各自的含义是什么 生产安全数据库录入 数据库的安全性及管理 数据库安全策略包含哪些 海淀数据库安全审计系统 建立农村房屋安全信息数据库 易用的数据库客户端支持安全管理 连接数据库失败ssl安全错误 数据库的锁怎样保障安全 科技互联网 互联网科技工作委员会 互联网科技公司电话 广州互联网络科技有限公司 互联网科技小额贷款 互联网科技宣传片 深圳市运趣互联网科技有限公司 中国科技互联网公司收入 昭通云南众福互联网科技有限公司 互联网系的金融科技公司 江阴互联网智能科技产品进口 互联网科技与大数据专业 链环科技传统企业怎么转型互联网 互联网科技人工智能实验室 电子商务与互联网科技的关系 深圳无忧互联网科技 领航科技大厦互联网公司 风投北京互联网科技 广州互联网高科技取餐柜 东营紫格互联网科技 手冲咖啡和咖啡机区别 成都互联网科技公司 互联网养老 桔豆科技 科技伦理 互联网公司 中国互联网有什么科技含量 承德科技产业互联网发展 注册互联网科技公司经营范围大全 佛山市翊博互联网络科技有限公司 互联网科技收购价值 长沙易易互联网科技有限公司
0