Android基础篇之逐帧动画(Frame by Frame)
来源:互联网 发布:手机数据恢复精灵 编辑:程序博客网 时间:2024/05/22 06:26
奔腾的小马效果图:
逐帧动画是一种常见的动画形式(Frame By Frame),通过多张图片连续播放实现的一种动画,类似于GIF,其原理是在“连续的关键帧”中分解动画动作,也就是在时间轴的每帧上逐帧绘制不同的内容,使其连续播放而成动画。 因为逐帧动画的帧序列内容不一样,不但给制作增加了负担而且最终输出的文件量也很大,但它的优势也很明显:逐帧动画具有非常大的灵活性,几乎可以表现任何想表现的内容,而它类似与电影的播放模式,很适合于表演细腻的动画。例如:人物或动物急剧转身、 头发及衣服的飘动、走路、说话以及精致的3D效果等等。
代码:
activity_main
<?xml version="1.0" encoding="utf-8"?><LinearLayout 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:orientation="vertical"> <ImageView android:background="@drawable/main" android:id="@+id/iv_imageview" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1"/> <LinearLayout android:layout_gravity="center_horizontal" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content"> <Button android:text="开始" android:layout_width="wrap_content" android:layout_height="wrap_content" android:onClick="start"/> <Button android:text="停止" android:layout_width="wrap_content" android:layout_height="wrap_content" android:onClick="stop"/> </LinearLayout></LinearLayout>
动画main.xml
<?xml version="1.0" encoding="utf-8"?><animation-list xmlns:android="http://schemas.android.com/apk/res/android" > <!-- 添加多个帧 --> <item android:drawable="@drawable/horse1" android:duration="60"/> <item android:drawable="@drawable/horse2" android:duration="60"/> <item android:drawable="@drawable/horse3" android:duration="60"/> <item android:drawable="@drawable/horse4" android:duration="60"/> <item android:drawable="@drawable/horse5" android:duration="60"/> <item android:drawable="@drawable/horse6" android:duration="60"/> <item android:drawable="@drawable/horse7" android:duration="60"/> <item android:drawable="@drawable/horse8" android:duration="60"/></animation-list>
MainActivity:
import android.os.Bundle;import android.app.Activity;import android.graphics.drawable.AnimationDrawable;import android.view.View;import android.widget.ImageView;public class MainActivity extends Activity { AnimationDrawable ad; ImageView iv; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); iv=(ImageView) findViewById(R.id.iv_imageview); ad =(AnimationDrawable) iv.getBackground(); } public void start(View v) { //开始 ad.start(); } public void stop(View v) { //停止 ad.stop(); }}
0 0
- Android基础篇之逐帧动画(Frame by Frame)
- 史上最简单android动画之frame by frame(帧动画)
- 帧动画(Frame By Frame)
- Android 动画系列之逐帧(Frame)动画详解
- Android动画效果之Frame Animation(逐帧动画)
- Android动画效果之Frame Animation(逐帧动画)
- Android动画效果之Frame Animation(逐帧动画)
- Android动画效果之Frame Animation(逐帧动画)
- android--连贯动画frame-by-frame
- 安卓动画之逐帧动画Frame-by-frame Animations详解
- Android 学习之逐帧动画(Frame)
- Android之Frame By Frame Animations
- Android基础夯实--重温动画(二)之Frame Animation
- Android开发之Frame动画(帧动画)
- Android(开发):动画之Frame动画
- Android动画之Frame Animation逐帧动画
- Android动画之逐帧动画(Frame Animation)实例详解
- Android动画(View Animation之Frame Animation(逐帧动画))
- Scrapy安装介绍-windows版
- C/C++——线程池:CThreadPoolManager
- const 小结
- 自定义布局实现头部搜索框
- phpstorm +xdebug+wampserver环境搭建
- Android基础篇之逐帧动画(Frame by Frame)
- 一道小学题引发的思考
- SpringMVC理论基础
- iOS解决键盘遮挡问题
- SQL SERVER 数据库的查询总结
- 浅谈Hadoop技术——HDFS
- php+apache 和 php+nginx的区别
- 冒泡排序(java)
- lightoj 1030 水概率