Simple Animation in Android
Basic animation can be achieved in following different ways.
- Use Transition of images.
- Frame Animation.
- Others (Tween Animation & NinePatchDrawable & ShapeDrawable)
Use Transition of images.
This type of animation shows cross-faded animation between the first and second layer. We can provide two different images for the transition & provide interval between their transitions.
Sample:
- Create transition xml.
Store this file with any name in your drawable folder. E.d. splash_animation.xml
<transition xmlns:android="http://schemas.android.com/apk/res/android"> |
- Create a layout with ImageView that will have this transition.
<?xml version="1.0" encoding="utf-8"?> |
- Write code to fetch transaction and use it in one of the Image View.
public class TransitionAnimationActivity extends Activity { setContentView(R.layout.splashlayout); // Show A Transitions for Splash image here. //Set interval for the transition between two image. //Fetch imageView from your layout and apply transition on the same. ImageView imageView= (ImageView) findViewById(R.id.splashImgView); } |
I wish i could take screen shot of that animation but sorry i can’t.
Next time i’ll describe how to achieve FRAME ANIMATION when you have more than one images to be shown.