现在我知道如何在android中绘制GIF图片了,代码如下:
public class GIFView extends View{
private Movie movie;
private InputStream is;
private long moviestart;
public GIFView(Context context) {
super(context);
is=getResources().openRawResource(R.drawable.anim_cerca);
movie=Movie.decodeStream(is);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
long now=android.os.SystemClock.uptimeMillis();
if (moviestart == 0)
moviestart = now;
int relTime = (int)((now - moviestart) % movie.duration());
movie.setTime(relTime);
movie.draw(canvas,10,10);
this.invalidate();
}
}
最后是movie.draw(canvas,x,y)
代码,其中x和y是gif图片的坐标(x=left,y=top)。但是我怎么能改变电影的宽度和高度呢?也许给出右边和底部的坐标,但是如何,在哪里?谢谢!