Android --- Frame动画示例
来源:互联网 发布:淘宝删除的购物车 编辑:程序博客网 时间:2024/05/17 03:53
Frame动画:
1、找到一组图片c01.jpg,c02.jpg,c03.jpg,c04.jpg,c05.jpg,copy到res/drawable目录下;
2、在res/drawable目录下新建XML文件:frame_anim.xml
<?xml version="1.0" encoding="utf-8"?><animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="false"> <item android:drawable="@drawable/c01" android:duration="500"/> <item android:drawable="@drawable/c02" android:duration="500"/> <item android:drawable="@drawable/c03" android:duration="500"/> <item android:drawable="@drawable/c04" android:duration="500"/> <item android:drawable="@drawable/c05" android:duration="500"/></animation-list>3、在res/layout目录下新建XML文件:frame_anim_layout.xml
<?xml version="1.0" encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:orientation="vertical"android:layout_width="match_parent"android:layout_height="match_parent"><ImageViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:scaleType="centerInside"android:id="@+id/imgFrame"android:background="@drawable/frame_anim"></ImageView><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"><Buttonandroid:text="开始"android:id="@+id/btnStart"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_weight="1.0"></Button><Buttonandroid:text="结束"android:id="@+id/btnEnd"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_weight="1.0"></Button></LinearLayout></LinearLayout>4、Activity文件中的代码:
package com.bison;import android.app.Activity;import android.graphics.drawable.AnimationDrawable;import android.os.Bundle;import android.view.View;import android.view.View.OnClickListener;import android.widget.Button;import android.widget.ImageView;public class AnimationDemoActivity extends Activity implements OnClickListener {// 开始按钮private Button btnStart;// 结束按钮private Button btnEnd;private ImageView imgFrame;// 声明Frame动画对象private AnimationDrawable frameAnim;/** 初始化 */public void init() {btnStart = (Button) findViewById(R.id.btnStart);btnEnd = (Button) findViewById(R.id.btnEnd);btnStart.setOnClickListener(this);btnEnd.setOnClickListener(this);imgFrame = (ImageView) findViewById(R.id.imgFrame);// 将ImageView的backgroud声明给Frame动画对象frameAnim = (AnimationDrawable) imgFrame.getBackground();}@Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);// 加载layout.frame_anim_layout页面setContentView(R.layout.frame_anim_layout);init();}public void onClick(View v) {// 判断按钮事件switch (v.getId()) {case R.id.btnStart:frameAnim.start();break;case R.id.btnEnd:frameAnim.stop();break;}}}
PS:Frame动画原理类似于电影胶片,一幕一幕的闪过,在人的视觉停留期快速变动,形成组图,产生动画。
- Android --- Frame动画示例
- Android Frame动画概述及示例
- Android:动画:Frame动画
- android tween、frame动画
- Android动画--Frame Animation
- android Frame动画
- Android---Frame动画
- Android Frame动画
- Android Frame动画实例
- android-Frame动画
- Android[动画] Frame Animation
- android动画-Frame Animation
- android动画-Frame Animation
- Android 逐帧(Frame)动画
- Android Frame动画
- android Frame帧动画
- android动画Frame、Tween
- 【Android动画】之Frame动画
- Tomcat下Servlet的开发
- iPhone/iPad开发札记2012/03/12 Audio Unit
- 小生杂谈
- 一些重要网址
- 自定义类加载器的实现
- Android --- Frame动画示例
- 188. Great men's sons seldom do well. 富不过三代
- html 锚点链接 图像热区链接
- windows phone 7 变砖恢复方法
- 手机上, 除了游戏, 还能做什么?
- 多囊肿都有哪些治疗方法
- 好书推荐二号首张1 2 3部
- 连接ACCESS 数据库不能使用 '';文件已在使用中。
- Objective-C中@property属性使用