这是从网上下载下来并且重新运行通过了的代码。
目录结构如下:
使用时只需要把pl.droidsonroids.gif包和libs文件夹拷到相对应的位置,然后调用如下代码加载就行
public class MainActivity extends Activity {
/** 或者xml文件里面android:src="@drawable/pikachu" */
private GifImageView gifImageView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
gifImageView = (GifImageView) findViewById(R.id.giv_demo);
try {
GifDrawable gifDrawable = new GifDrawable(getResources(),
R.drawable.pikachu);
gifImageView.setImageDrawable(gifDrawable);
} catch (NotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}