I was studying the ApiDemos code samples and saw a sample which was animating a gif image. It was working fine. When I replaced that gif image i.e. R.drawable.animated_gif with my own gif image, it squashes/distorted the gif image and was not working properly. Any idea? Here is the onDraw() method of MyView class:
@Override protected void onDraw(Canvas canvas) {
canvas.drawColor(0xFFCCCCCC);
long now = android.os.SystemClock.uptimeMillis();
if (mMovieStart == 0) {
mMovieStart = now;
}
if (mMovie != null) {
int dur = Math.max(mMovie.duration(), 1);
int pos = (int)(now % dur);
mMovie.setTime(pos);
mMovie.draw(canvas, getWidth() - mMovie.width(),
getHeight() - mMovie.height());
invalidate();
}
}