有很多方法。使用webview是最好的方法吗?帧动画是否适合它?
答案 0 :(得分:1)
我尝试使用帧动画。但是显示.gif的有效方式是什么?我也尝试过使用webview。这是代码
public class GifWebView extends View {
private Movie mMovie;
InputStream mStream;
long mMoviestart;
private boolean play;
public GifWebView(Context context, InputStream stream) {
super(context);
mStream = stream;
setPlay(true);
mMovie = Movie.decodeStream(mStream);
}
@Override
protected void onDraw(Canvas canvas) {
canvas.drawColor(Color.TRANSPARENT);
super.onDraw(canvas);
final long now = SystemClock.uptimeMillis();
if (mMoviestart == 0) {
mMoviestart = now;
}
final int relTime = (int) ((now - mMoviestart) % mMovie.duration());
mMovie.setTime(relTime);
mMovie.draw(canvas, 20, 20);
if (play) {
Log.i("reltime", "" + relTime + ",duration:" + mMovie.duration());
this.invalidate();
}
}
@Override
public boolean onTouchEvent(android.view.MotionEvent event) {
return true;
};
public boolean isPlay() {
return play;
}
答案 1 :(得分:0)
如果您想要显示gif
图片(没有WebView
),则必须将其分解为帧并为其中的每一个制作动画,请查看here :
另一个意思是:
http://www.imagemagick.org/Usage/anim_basics/#adjoin
OR