先看效果后上代码:

动画开始----

动画切换的界面----

动画播放完毕后的跳转界面-----

重要的方法:

                  imageView.setBackgroundResource(R.anim.framebyframe);

		animationDrawable = (AnimationDrawable) imageView.getBackground();
// 设置是否循环播放,false是循环播放,true只播放一遍
// animationDrawable.setOneShot(false);
animationDrawable.start();
//animationDrawable.setOneShot(false);是否循环播放
  //animationDrawable.stop();停止播放
  //animationDrawable.isRunning();//是否播放
  //animationDrawable.getNumberOfFrames();//播放帧
  //animationDrawable.getFrame(index); 返回制定索引的 Drawable对象
  //animationDrawable.getDuration(i);停留的时间

项目的开发结构:

完整代码:

SplashActivity.java源码:

package com.example.lesson18_framebyframe;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.Menu;
import android.widget.ImageView; /**
* 2013-6-27 下午3:41:20
*
* @author 乔晓松
*/
public class SplashActivity extends Activity { private ImageView imageView;
private AnimationDrawable animationDrawable; @SuppressLint("HandlerLeak")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); imageView = (ImageView) findViewById(R.id.imageView1);
imageView.setBackgroundResource(R.anim.framebyframe); animationDrawable = (AnimationDrawable) imageView.getBackground();
// 设置是否循环播放,false是循环播放,true只播放一遍
// animationDrawable.setOneShot(false);
animationDrawable.start();
new Handler() {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
if (msg.what == 1) {
Intent intent = new Intent(SplashActivity.this,
MainActivity.class);
startActivity(intent); SplashActivity.this.finish();
}
}
}.sendEmptyMessageDelayed(1, 3000);
// this.finish();
} @Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}

framebyframe.xml源码

<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="true" > <item
android:drawable="@drawable/span"
android:duration="1000"/>
<item
android:drawable="@drawable/span1"
android:duration="1000"/>
<item
android:drawable="@drawable/psbpan"
android:duration="1000"/>
<item
android:drawable="@drawable/ic_launcher"
android:duration="1000"/> </animation-list>

MainActivity.java源码:

package com.example.lesson18_framebyframe;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView; /**
* 2013-6-27 下午3:46:39
*
* @author 乔晓松
*/
public class MainActivity extends Activity { @Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
TextView tv = new TextView(this);
tv.setText("主页面");
this.setContentView(tv);
}
}

layout-main.xml布局文件:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" > <ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
tools:ignore="ContentDescription" /> </RelativeLayout>

清单文件:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.lesson18_framebyframe"
android:versionCode="1"
android:versionName="1.0" > <uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" /> <application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.lesson18_framebyframe.SplashActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.example.lesson18_framebyframe.MainActivity" >
</activity>
</application> </manifest>

Java乔晓松-android中的帧动画FrameByFrame的更多相关文章

  1. Java乔晓松-android中调用系统拍照功能并显示拍照的图片

    android中调用系统拍照功能并显示拍照的图片 如果你是拍照完,利用onActivityResult获取data数据,把data数据转换成Bitmap数据,这样获取到的图片,是拍照的照片的缩略图 代 ...

  2. Java乔晓松-android中上传图片到服务器Tomcat(Struts2)

    在做android开发的时候,有时你会用到图片的上传功能,在我的android项目中,我是选中图片,点击上传多张图片 android客户端上传图片部分的代码如下: package com.exampl ...

  3. Java乔晓松-android中获取图片的缩略图(解决OutOfMemoryError)内存溢出的Bug

    由于android获取图片过大是会出现内存溢出的Bug 07-02 05:10:13.792: E/AndroidRuntime(6016): java.lang.OutOfMemoryError 解 ...

  4. Java乔晓松-android的四大组件之一Service(服务的绑定)

    android的四大组件之一Service(服务的绑定) 怎么绑定服务,又怎么解除服务,代码如下: MainActivity.java源码: package com.example.lesson14_ ...

  5. Android中的帧动画与补间动画的使用

    前言 在日常开发中,我们有时候须要一些好看的动画效果,这时能够充分利用Android提供的这几种动画来实现. Android提供了3种类型的动画: 补间动画:补间动画能够应用于View,让你能够定义一 ...

  6. Java时间间隔问题在Android中的使用

    转载请注明出处:http://www.cnblogs.com/cnwutianhao/p/6606720.html 假设我们在做项目的时候,获取到了一段音频,也知道音频长度,那么我们想对音频做一些处理 ...

  7. Android简单逐帧动画Frame的实现(三)

    android之动画(三)通过AnimationDrawable控制逐帧动画     android与逐帧动画: 效果图: 当我们点击按钮时,该图片会不停的旋转,当再次点击按钮时,会停止在当前的状态. ...

  8. Android简单逐帧动画Frame的实现(二)

    Android简单逐帧动画Frame的实现   Android简单逐帧动画Frame的实现 1.逐帧动画 即是通过播放预先排序好的图片来实现动态的画面,感觉像是放电影. 2.实现步骤: 1. 在工程里 ...

  9. android中设置Animation 动画效果

    在 Android 中, Animation 动画效果的实现可以通过两种方式进行实现,一种是 tweened animation 渐变动画,另一种是 frame by frame animation ...

随机推荐

  1. Unity3D开发必备神器(Visual Studio Tools for Unity)

    Unity3D开发必备神器(Visual Studio Tools for Unity) 开发Unity3D程序你用的什么IDE呢? 1.MonoDevelop 2.VS 可能你的回答是这样的,我用的 ...

  2. iOS:由URL成员UIImage

    很多时候,我们只能得到URL.然后,需要建立一个UIImage. 在正常情况下,.我们一般通过SDWebImage直接施工UIImageVIew的image,如何使用URL直接施工UIImage它? ...

  3. Controller 的 Action 只接受 Ajax 请求

    ASP.NET MVC 使 Controller 的 Action 只接受 Ajax 请求. 2014-08-27 14:19 by h82258652, 555 阅读, 2 评论, 收藏, 编辑 首 ...

  4. Oracle的SOME,ANY和ALL操作

    平时很少用的这几个操作,今天遇到了.于是又看了一下文档. SOME和ANY一样,是比较宽松的,类似于OR.满足其中任何一个都可以. ALL要求严格一些,类似于AND,必须全部满足才可以. 不能单独使用 ...

  5. 如何用VB获得Windows各类系统目录

    现在有很多关于如何用VB获得Windows目 录的文章,但大都只讲到如何获得Windows目录和System目录,有时候我们却需要获得像"我的文档"这样的目录("我的文档 ...

  6. ant svn

    <!-- 检出代码 这里使用 export 不是checkout 二者区别 checkout会svn相关信息文件检出,export只是检出最新的文件--> <target name= ...

  7. Jquery中获取iframe的代码方法

    父窗口中操作iframe:window.frames["iframeChild"].document //假如iframe的id为iframeChild 在子窗口中操作父窗口:wi ...

  8. 受益匪浅的材料orz

    看到了xhr大神制作的材料 仰慕良久,受益匪浅,必将永记在心,蒟蒻长跪不起 考前一定要膜拜!

  9. C# 求精简用一行代码完成的多项判断 重复赋值

    C# 求精简用一行代码完成的多项判断 重复赋值 哈哈,说实话,个人看着这么长的三元操作也麻烦,但是我也只想到了这样三元判断句中执行方法体能够写到一行,追求的终极目的是,用一行实现这个过程,而且简单,由 ...

  10. 【hanoi】hanoi移动次数和移动步骤

    #include<stdio.h> #include<stdlib.h> //移动次数 int hanoi(int num) { ; ) { ; } else { all = ...