当前位置: 代码迷 >> Android >> Android 加载gif图片 (详细应用)
  详细解决方案

Android 加载gif图片 (详细应用)

热度:102   发布时间:2016-05-01 17:57:40.0
Android 加载gif图片 (详细运用)

----------加入包

GifView

-----------xml
<com.ant.liao.GifView
        android:id="@+id/gif1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="240px"
        android:layout_gravity="center_horizontal|center_vertical"
        android:enabled="false"
        android:paddingRight="14px" />


------------.java
package com.test;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Toast;

import com.ant.liao.GifView;

public class TestAction extends
  Activity {

 private GifView gf1;

 private boolean f = true;

 public void onCreate(Bundle icicle) {
  super.onCreate(icicle);
  // Log.d("dddddddddd",Environment.getRootDirectory

().getAbsolutePath());
  // LinearLayout ll = new LinearLayout(this);
  // LayoutParams la = new LayoutParams

(LayoutParams.FILL_PARENT,
  // LayoutParams.FILL_PARENT);
  //
  // ll.setLayoutParams(la);
  // gf1 = new GifView(this);
  // gf2 = new GifView(this);
  //
  // gf1.setGifImage(R.drawable.gif1);
  // gf2.setGifImage(R.drawable.gif2);
  //
  // ll.addView(gf1);
  // ll.addView(gf2);
  //
  // setContentView(ll);

  setContentView(R.layout.gif);
  gf1 = (GifView) findViewById(R.id.gif1);
  gf1.setGifImage(R.drawable.g1);
  gf1.setOnClickListener(new OnClickListener() {

   @Override
   public void onClick(View v) {
    // TODO Auto-generated method stub
    // android.os.Process
    // .killProcess(android.os.Process
    // .myPid());

    Toast.makeText(
      TestAction.this,
      "loveyou", 1000)
      .show();

   }
  });

  //
  // gf2 = (GifView)findViewById(R.id.gif2);
  // gf2.setGifImageType(GifImageType.COVER);
  // gf2.setShowDimension(300, 300);
  // gf2.setGifImage(R.drawable.a);
  // gf2.setOnClickListener(this);
 }

 // public void onClick(View v) {
 // if (f) {
 // gf1.showCover();
 // f = false;
 // } else {
 // gf1.showAnimation();
 // f = true;
 // }
 // }
}

  相关解决方案