zoukankan      html  css  js  c++  java
  • Android显示GIF动画完整示例(一)

    MainActivity如下:

    package cc.testgif;
    
    import com.ant.liao.GifView;
    import com.ant.liao.GifView.GifImageType;
    import android.os.Bundle;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.app.Activity;
    /**
     * Demo描述:
     * 利用第三方控件显示GIF动画
     * 
     * 参考资料:
     * http://blog.csdn.net/leilu2008/article/details/6822517#
     * http://code.google.com/p/gifview/source/checkout
     * Thank you very much
     */
    public class MainActivity extends Activity {
        private GifView mGifView;
    	@Override
    	protected void onCreate(Bundle savedInstanceState) {
    		super.onCreate(savedInstanceState);
    		setContentView(R.layout.main);
    		init();
    	}
    
    	private void init(){
    		mGifView = (GifView) findViewById(R.id.gifView);
    		mGifView.setGifImage(R.drawable.gif);
    		mGifView.setOnClickListener(new OnClickListener() {
    			@Override
    			public void onClick(View v) {
    				System.out.println(" Click ");
    			}
    		});
    		mGifView.setShowDimension(300, 300);
    		//加载方式
    		mGifView.setGifImageType(GifImageType.COVER);
    	}
    
    }
    


     

    main.xml如下:

    <RelativeLayout 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"
        >
    
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/hello_world"
            android:layout_centerHorizontal="true" />
        
        <com.ant.liao.GifView
            android:id="@+id/gifView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:enabled="false"
            android:layout_centerInParent="true" />
    
    </RelativeLayout>


     

  • 相关阅读:
    python基础——操作系统简介
    python 3 输入和输出
    C++学习笔记——C++简介
    ML机器学习导论学习笔记
    Linux常用基本指令——文件处理命令
    Oracle数据库从入门到精通-分组统计查询
    PL/SQL编程基础——PL/SQL简介
    django 第五课自定义模板过滤器与标签
    Python之GUI的最终选择(Tkinter)
    Python利用pandas处理Excel数据的应用
  • 原文地址:https://www.cnblogs.com/suncoolcat/p/3324949.html
Copyright © 2011-2022 走看看