android Frame-By-Frame Animations(一帧一帧地播放动画)的使用
来源:互联网 发布:js除法取整 编辑:程序博客网 时间:2024/05/16 08:01
程序功能,点击按钮时,图片一张一张循环播放:
直接来代码:
AppMain.java
package lxy.litsoft;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 AppMain extends Activity {//声明对象ImageView disPic;Button btDis;public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); //实例化对象 disPic = (ImageView)findViewById(R.id.imageView01); btDis = (Button)findViewById(R.id.button01); //绑定监听器 btDis.setOnClickListener(new ButtonListener()); }//按钮的监听器实现class ButtonListener implements OnClickListener{public void onClick(View v) {//动画播放disPic.setBackgroundResource(R.drawable.anim);AnimationDrawable animationDrawable = (AnimationDrawable)disPic.getBackground();animationDrawable.start();}}}
main.xml
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" ><TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello"/> <ImageView android:id="@+id/imageView01" android:layout_width="wrap_content" android:layout_height="wrap_content"></ImageView> <Button android:id="@+id/button01" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Anim"></Button></LinearLayout>
res/drawable/anim.xml
<animation-listxmlns:android="http://schemas.android.com/apk/res/android"android:oneshot="false"><item android:drawable="@drawable/p30"android:duration="300"/><item android:drawable="@drawable/p31"android:duration="300"/><item android:drawable="@drawable/p32"android:duration="300"/><item android:drawable="@drawable/p33"android:duration="300"/><item android:drawable="@drawable/p34"android:duration="300"/><item android:drawable="@drawable/p35"android:duration="300"/><item android:drawable="@drawable/p36"android:duration="300"/><item android:drawable="@drawable/p37"android:duration="300"/></animation-list>
其中每一个item就是一帧的资源,android:drawable是图片资源,android:duration是每一帧的显示时间。
- android Frame-By-Frame Animations(一帧一帧地播放动画)的使用
- Android常用动画Frame-By-Frame Animations的使用
- Android Animation动画(Frame-By-Frame Animations 、Tween Animations 、Property Animation)的详解
- Frame By Frame Animations
- Android之Frame By Frame Animations
- Frame-By-Frame Animations的使用方法
- Animations之Frame-By-Frame Animations的使用方法
- android中animation之Frame-By-Frame Animations
- android--连贯动画frame-by-frame
- 帧动画(Frame By Frame)
- 安卓动画之逐帧动画Frame-by-frame Animations详解
- 史上最简单android动画之frame by frame(帧动画)
- 安卓动画之帧动画(Frame Animations)
- Android Frame(逐帧动画)的使用
- [Android] Android frame by frame animation动画显示
- android动画——Frame by Frame Animation
- android frame by frame AnimationDrawable 实现动画效果
- Android开发之对Frame动画播放的补充
- 英特尔SR-IOV实现PCI硬件资源共享
- Ubuntu 11.10 上很棒的一组主题
- SQLServer 2005 Row_Number 的使用
- FltGetFileNameInformation+VISTA+IRP_MJ_NETWORK_QUERY_OPEN+BSOD
- UIKeyboard
- android Frame-By-Frame Animations(一帧一帧地播放动画)的使用
- iphone ios debug 调试时如何查看、监视变量
- timestamp(时间戳)详解
- libxml++
- [C#] DBNull、Null和String.Empty的区别
- 【开发者实用工具】移动应用信息统计
- plsql知识梳理-计划任务
- android 源码 打包成apk的实现
- 页面停留访问计时方案的设计与实现