zoukankan      html  css  js  c++  java
  • Frame动画

    程序截图:



    原理:

    其实所谓的帧动画,说白了,就是每隔一段时间显示一张图片.......

    实现步骤如下:

    1、/res/drawable/下放入各种图片(即你要用来制作动画的图片),然后新建一个frame.xml的文件用来决定图片是显示顺序

    frame.xml的代码如下:

    <?xml version="1.0" encoding="utf-8"?>
    <animation-list xmlns:android="http://schemas.android.com/apk/res/android" >
         <item
            android:drawable="@drawable/a"
            android:duration="200" />
    
         <item
            android:drawable="@drawable/b"
            android:duration="200" />
         
         <item
            android:drawable="@drawable/c"
            android:duration="200" />
         
         <item
            android:drawable="@drawable/d"
            android:duration="200" />
    
         <item
            android:drawable="@drawable/e"
            android:duration="200" />
         
         <item
            android:drawable="@drawable/f"
            android:duration="200" />
         
    </animation-list>
    


    其中item的写法可以去android官网中查看API。。。。


    2、main.xml

    <?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" >
        
        <ImageView 
            android:id="@+id/iv"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/frame"
            />
        
        <Button 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="开始"
            android:onClick="start"
            />
    
         <Button 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="结束"
            android:onClick="stop"
            />
    </LinearLayout>
    



    3、MainActivity

    package com.njupt.frame1;
    
    import android.os.Bundle;
    import android.app.Activity;
    import android.graphics.drawable.AnimationDrawable;
    import android.view.Menu;
    import android.view.View;
    import android.widget.ImageView;
    
    public class MainActivity extends Activity {
    
    	private ImageView iv;
    	private AnimationDrawable ad;
    	
    	@Override
    	protected void onCreate(Bundle savedInstanceState) {
    		super.onCreate(savedInstanceState);
    		setContentView(R.layout.main);
    	    
    		iv = (ImageView) findViewById(R.id.iv);
    	}
    
    	public void start(View v){
    		ad =  (AnimationDrawable) iv.getBackground();
    		ad.start();
    	}
    	
    	public void stop(View v){
    		ad.stop();
    	}
    	@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;
    	}
    
    }
    


  • 相关阅读:
    webix datadable 分页重加载
    webix datatale 分頁加载两次
    webix .datatable 表格分页
    webix datatable 列头加tooltip
    webix.tree 修改图标
    webix icon 图标
    spring 模板发送邮件
    spring发QQ邮件
    严重: Context initialization failed org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [cn.itcast.javaee.springmvc.app06.HelloAction] for bean with name '/hello.action' de
    严重: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/springmvc-day01]]
  • 原文地址:https://www.cnblogs.com/pangblog/p/3331375.html
Copyright © 2011-2022 走看看