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();//启动

    完整的代码下载

  • 相关阅读:
    Scalaz(18)- Monad: ReaderWriterState-可以是一种简单的编程语言
    Scalaz(17)- Monad:泛函状态类型-State Monad
    Scalaz(16)- Monad:依赖注入-Dependency Injection By Reader Monad
    spring mvc注解和spring boot注解
    mac查看网页时翻页
    springboot工程的结构
    关于springboot
    mac锁屏
    关于mac上的maven
    debian dhcp配置
  • 原文地址:https://www.cnblogs.com/vir56k/p/2099080.html
Copyright © 2011-2022 走看看