Animation Image Used in Android Tutorial
GIF Image used in Android Application. for that you need to use following code implementation in your android project.
That is the UI of this tutorial demo for Android.
public AnimationView(Context context,AttributeSet attrs) { super(context,attrs); setFocusable(true); java.io.InputStream is; is = context.getResources().openRawResource(R.drawable.th_welcome); if (DECODE_STREAM) { mMovie = Movie.decodeStream(is); } else { byte[] array = streamToBytes(is); mMovie = Movie.decodeByteArray(array, 0, array.length); } }
Other things to draw Canvas can be used the following code.
@Override public void onDraw(Canvas canvas) { long now = android.os.SystemClock.uptimeMillis(); if (mMovieStart == 0) { // first time mMovieStart = now; } if (mMovie != null) { int dur = mMovie.duration(); if (dur == 0) { dur = 3000; } int relTime = (int) ((now - mMovieStart) % dur); Log.d("", "real time :: " +relTime); mMovie.setTime(relTime); mMovie.draw(canvas, getWidth() - 200, getHeight()-200); invalidate(); } }
No comments:
Post a Comment