Android常用动画Frame-By-Frame Animations的使用
2013-09-02 15:16
501 查看
在Android的动画中有一种叫做Frame by Frame 的动画效果,就是跟Flash播放一样,是一帧一帧地显示,如果动画是连续并且有规律的话,就跟播放视频一样。
首先在drawable目录下添加anim_nv.xml文件,添加需要显示的图片和间隔时间
布局文件
在Activity中
这样一个连续显示图片的效果就完成了。
源码下载:
点击打开链接
首先在drawable目录下添加anim_nv.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/psb1" android:duration="500"/> <item android:drawable="@drawable/psb2" android:duration="500"/> <item android:drawable="@drawable/psb3" android:duration="500"/> <item android:drawable="@drawable/psb4" android:duration="500"/> </animation-list>
布局文件
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/hello_world" /> <Button android:id="@+id/alpha" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="动画效果演示"/> <ImageView android:id="@+id/image" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="50dip"/> </LinearLayout>
在Activity中
package com.example.animation; 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; import com.example.widgetdemo.R; public class AnimationXmlDemo3 extends Activity { private Button alpha = null; private ImageView image = null; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.animation_xml3); alpha = (Button) findViewById(R.id.alpha); image = (ImageView) findViewById(R.id.image); alpha.setOnClickListener(new alphaListener()); } class alphaListener implements OnClickListener { @Override public void onClick(View arg0) { // TODO Auto-generated method stub //为图片添加图片背景 image.setBackgroundResource(R.drawable.anim_nv); AnimationDrawable animationDrawable = (AnimationDrawable) image .getBackground(); animationDrawable.start(); } } }
这样一个连续显示图片的效果就完成了。
源码下载:
点击打开链接
相关文章推荐
- Android常用动画Frame-By-Frame Animations的使用
- android Frame-By-Frame Animations(一帧一帧地播放动画)的使用
- android Frame-By-Frame Animations(一帧一帧地播放动画)的使用
- Android Animation动画(Frame-By-Frame Animations 、Tween Animations 、Property Animation)的详解
- 使用android frame动画定义自己的ProgressBar
- android动画——Frame by Frame Animation
- Android 动画使用的常用场景
- android frame by frame AnimationDrawable 实现动画效果
- Android游戏开发之使用AnimationDrable实现Frame动画
- Android常用动画Animation的使用
- [Android] Android frame by frame animation动画显示
- Android常用动画Animation的使用
- Android游戏开发之使用AnimationDrable实现Frame动画(三十一)
- Java乔晓松-android中的帧动画FrameByFrame
- 史上最简单android动画之frame by frame(帧动画)
- Android游戏开发之使用AnimationDrable实现Frame动画(三十一)
- Android常用动画alpha和rotate同时使用
- Android自定义控件7----滑动动画scrollTo/scrollBy使用
- 帧动画Frame-by-Frame Animation的使用方法
- Android常用动画ViewGroup的使用