Hi,
You can usr Movie to play the gif file like this code :
public class CGifView extends View {
private Movie movie;
private long movieStart = 0;
public CGifView(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
TypedArray typedArray =
context.obtainStyledAttributes(attributeSet, R.styleable.GifView);
int gifFileId = -1;
int attr;
for (int i = 0; i < typedArray.getIndexCount(); i++) {
attr = typedArray.getIndex(i);
if (attr == R.styleable.GifView_gif_file) {
gifFileId = typedArray.getResourceId(attr, -1);
break;
}
}
if (gifFileId != -1) {
InputStream inputStream =
context.getResources().openRawResource(gifFileId);
movie = Movie.decodeStream(inputStream);
}
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (movie != null) {
long now = android.os.SystemClock.uptimeMillis();
if (movieStart == 0)
movieStart = now;
int relTime = (int) ((now - movieStart) % movie.duration());
movie.setTime(relTime);
movie.draw(canvas, 0, 0);
this.invalidate();
}
}
}
On Tuesday, September 1, 2009 7:17:45 PM UTC+4:30, Nithin wrote:
>
> Hi,
>
> I just want to display an animated GIF file. I tried and its static
> only, its not animating. There are other ways like frame by frame or
> using animation classes.
>
> But I want to know, whether android supports animated GIF image.
>
> Thanks
> Nithin
--
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
You received this message because you are subscribed to the Google Groups
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.