有两种方法

第一种  麻烦,需要把一张gif图分解帧,然后将帧一张一张绘制,很麻烦。



第二种,可以直接在网上下载一个drawable.gif 包

包里libs文件夹下有以下文件

wKioL1XQZ8ngIWkmAACdDwhxofA026.jpg












将这些文件全部复制到你写的安卓程序的libs文件夹下(有两个没用,不过没关系,都复制进去就行),这样gif 包就完成了,接下来就可以添加gif图片了!!



新建一个Layout


<?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" >
    <pl.droidsonroids.gif.GifImageView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/gif"
    />
    

</LinearLayout>


然后在MainActivity里


public class Begin_gif extends Activity {
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate( savedInstanceState );
        setContentView(R.layout.begin_gif);

        }

}



这样就可以播放你的gif图片了!!!


gif包在附件里,也可以从网上搜,然后下载