私のAndroidアプリケーションでは、私はgifを表示するためにMovieを使用していますが、私は直面している問題は、画像の1フレームだけで空白の画面を表示している。
gifをAndroidで表示するには、より良い方法を教えてください。
私が使用していたコードはandroidのgif画像を処理する
public MYGIFView(Context context, InputStream is, int i, int j,int screenWidth,int screenHeight) {
super(context);
//is=context.getResources().openRawResource(red);
movie=Movie.decodeStream(is);
xcoordinate = i;
ycoordinate = j;
viewWidth = screenWidth;
viewHeight = screenHeight;
setLayoutParams(new LayoutParams(viewWidth,viewHeight));
}
@Override
protected void onDraw(Canvas canvas) {
if(movie != null) {
long now = android.os.SystemClock.uptimeMillis();
int dur = Math.max(movie.duration(), 1); // is it really animated?
int pos = (int)(now % dur);
movie.setTime(pos);
movie.draw(canvas,xcoordinate, ycoordinate);
}
Thread.sleep(50); //収率は20fps あなたのために新しい地獄を作る必要があります –