启动某项程序时我们往往都能看到不同的“开机动画”,千变万化的动画也只不过是四种基本动画衍变美化而成的。
四种android动画效果:
- alpha 渐变透明度动画效果
- scale 渐变尺寸伸缩动画效果
- translate 画面转换位置移动动画效果
- rotate 画面转移旋转动画效果
最简单的莫过于渐变透明效果,单单这一种就可完成渐隐渐现的动画效果(用于渐现渐隐的可以是整个欢迎页面也可以是欢迎页面里的一部分):
1)、 在res里新建anim文件夹用来盛放动画定义的动作文件:
<set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_interpolator"> <alpha android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="2000"/> <alpha android:fromAlpha="1.0" android:toAlpha="0.0" android:startOffset="3000" android:duration="3000"/> </set>fromalpha即开始的透明度,toalpha即结束时的透明度,duration为时间(单位毫秒)。
2)、定义布局文件(layout):
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center_vertical|center_horizontal" android:orientation="vertical" > <ImageView android:id="@+id/welcom_logo" android:layout_width="fill_parent" android:layout_height="fill_parent" android:src="@drawable/welcome" /> </LinearLayout>这里和以往没有任何不同,只需对要渐现渐隐的图片进行id标示。
3)、实现方法(Activity):
欢迎页面顾名思义只是装饰作用一闪而过不需要返回键进行操作。
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。