Animation Tutorial

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();
      }
    }

       


For Source Code click here to Download.

Comments

  1. Android Chat Head Library
    Chat head is new feature which floats on screen instead of residing inside conventional application. This feature is very continent for multitasking as user can work and chat at the same time.
    Android Chat Head Library

    ReplyDelete

Post a Comment

Popular posts from this blog

Horizontal ListView Tutorial

Android Video Capture Tutorial

Analog Clock Widget Tutorial