zoukankan      html  css  js  c++  java
  • android开发(10) 逐帧动画演示(Frame Animation)

    逐帧动画就是将多张图片按顺序展示,从而产生一种动态的效果。

    ---------------

    下面是我的代码演示

    1.准备几张连续的图片,编写动画描述文件(在anim资源文件夹下新建一个XML)。

    <?xml version="1.0" encoding="utf-8"?>
    <animation-list xmlns:android="http://schemas.android.com/apk/res/android"  
      android:oneshot
    ="true">   
           
    <item android:drawable="@drawable/c1" android:duration="200" />  
         
    <item android:drawable="@drawable/c2" android:duration="200" /> 
         
    <item android:drawable="@drawable/c3" android:duration="200" />
         
    <item android:drawable="@drawable/c4" android:duration="200" />
         
    <item android:drawable="@drawable/c5" android:duration="200" />
         
    <item android:drawable="@drawable/c6" android:duration="200" />
    </animation-list>

    2.在窗体里放置一个ImageView 控件,并在代码里编写

            _imageView1 = (ImageView)findViewById(R.id.imageView1);//放置的ImageView 控件
            
            
    //设置动画背景
            _imageView1.setBackgroundResource(R.anim.animation_list); //其中R.anim.animation_list就是上一步准备的动画描述文件的资源名
     
            //获得动画对象
            _animaition = (AnimationDrawable) _imageView1.getBackground();
     

    3.启动动画

                    //是否仅仅启动一次?
                    _animaition.setOneShot(false);
                    
    if(_animaition.isRunning())//是否正在运行?
                    {
                        _animaition.stop();//停止
                    }
                    _animaition.start();//启动

    完整的代码下载

  • 相关阅读:
    函数式编程
    _.pick lodash
    Vue mixins extend
    js 导入json配置文件
    FormData
    shell中的调试与计算
    linux命令(6/10):find 命令
    Linux性能测试分析命令_sar+iostat+vmstat+top
    linux命令详解之(at)
    linux命令(6/9):watch命令
  • 原文地址:https://www.cnblogs.com/vir56k/p/2099080.html
Copyright © 2011-2022 走看看