Step1)put a Gif image in drawable folder
Step2)Make
GifViewActivity and
GifViewClass as follows
public class GifViewActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(new GifViewClass(this));
}
private class GifViewClass extends View {
Movie movie;
GifViewClass(Context context) {
super(context);
//Gif image from drawable folder
movie = Movie.decodeStream(
context.getResources().openRawResource(
R.drawable.gif_image));
}
@Override
protected void onDraw(Canvas canvas) {
if (movie != null) {
movie.setTime(
(int) SystemClock.uptimeMillis() % movie.duration());
movie.draw(canvas, 0, 0);
invalidate();
}
}
}
}
No comments:
Post a Comment