安卓开发动画效果
2015-05-04 21:43
183 查看
动画在很多应用中都存在,尤其是游戏类的应用,在做android开发时,UI往往是最费时间,但一个效果炫丽的UI也往往是一款应用吸引人的地方。而动画效果可以做出很多炫丽的效果,下面列举下android的动画开发——Animation的动画效果。
动画类型
Android的animation由四种类型组成
XML中
JavaCode中
Android动画模式
Animation主要有两种动画模式:
一种是tweened animation(渐变动画)
一种是frame by frame(画面转换动画)
在XML文件中定义动画
① 打开Eclipse,新建Android工程
② 在res目录中新建anim文件夹
③ 在anim目录中新建一个myanim.xml(注意文件名小写)
④ 加入XML的动画代码
共同的布局文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:Android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/Alpha"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="淡入淡出" />
<Button
android:id="@+id/scale"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="缩放效果" />
<Button
android:id="@+id/rotate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="旋转效果" />
<Button
android:id="@+id/translate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="移动效果" />
</LinearLayout>
<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/a" />
</LinearLayout>
动画类型
Android的animation由四种类型组成
XML中
alpha | 渐变透明度动画效果 |
scale | 渐变尺寸伸缩动画效果 |
translate | 画面转换位置移动动画效果 |
rotate | 画面转移旋转动画效果 |
AlphaAnimation | 渐变透明度动画效果 |
ScaleAnimation | 渐变尺寸伸缩动画效果 |
TranslateAnimation | 画面转换位置移动动画效果 |
RotateAnimation | 画面转移旋转动画效果 |
Animation主要有两种动画模式:
一种是tweened animation(渐变动画)
XML中 | JavaCode |
alpha | AlphaAnimation |
scale | ScaleAnimation |
XML中 | JavaCode |
translate | TranslateAnimation |
rotate | RotateAnimation |
① 打开Eclipse,新建Android工程
② 在res目录中新建anim文件夹
③ 在anim目录中新建一个myanim.xml(注意文件名小写)
④ 加入XML的动画代码
共同的布局文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:Android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/Alpha"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="淡入淡出" />
<Button
android:id="@+id/scale"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="缩放效果" />
<Button
android:id="@+id/rotate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="旋转效果" />
<Button
android:id="@+id/translate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="移动效果" />
</LinearLayout>
<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/a" />
</LinearLayout>
相关文章推荐
- 安卓开发20:动画之Animation 详细使用-主要通过java代码实现动画效果
- 安卓开发20:动画之Animation 详细使用-主要通过java代码实现动画效果
- 安卓开发-动画效果学习
- 关于安卓开发中Activity动画切换效果无效的一个总结
- 安卓开发20:动画之Animation 详细使用-主要通过java代码实现动画效果
- 安卓开发20:动画之Animation 详细使用-主要通过java代码实现动画效果
- 安卓开发基础之动画(二)帧动画效果的实现
- 安卓开发加载中效果类似progressDialog效果加载动画
- 安卓开发基础之动画(一)补间动画的各种效果的实现
- 安卓简单开发-安卓自带几种动画效果
- 【安卓开发】用PageTransformer打造更好的动画效果
- 【安卓开发】用PageTransformer打造更好的动画效果
- ios开发学习--动画(Animation)效果源码分享--系列教程1
- ios开发核心动画五:图标抖动效果--CAKeyframeAnimation
- Android开发中MJRefresh自定义刷新动画效果
- Android动画开发——Animation动画效果
- android开发游记:弹出窗和底部弹出窗的实现和动画效果
- 【Android开发日记】之基础篇(二)——Android的动画效果
- [安卓开发]弹幕滚幕效果自定义View之BarrageView|支持点击事件|隐藏不滞留|颜色随机|大小速度范围随机
- Android开发之常用的loading等待效果实现,仿微博等待动画。两种实现方式详解