Creating basic animation in android is very easy. We can implement animation effect in our android app/game simply using XML or Java code. In this tutorial, I am going to show how to make slide down and slide up animation in android using XML and little bit java code.

Here I have created two xml file in res/anim directory for top to down animation and bottom to top animation and linked these file from java code.

Blinking Animation in Android Application
How to Add Ripple Effect/Animation to a Android Button
Android Rotate Animation Example

Android Example: How to Setup Slide Up and Down Animation in Android

First create two xml files slide_up_animation.xml and slide_down_animation.xml in res/anim folder and add the following content.

res/anim/ slide_down_animation.xml

res/anim/ slide_up_animation.xml

XML Layout File

In XML layout file I have an ImageView and two Buttons inside LinearLayout. Following is the complete content of XML layout file.

res/layout/ slide_up_down_animation_layout.xml

Java Activity File

Now, we have to work in our app java activity file to make working slide down and slide up animation. Following is the complete java code of java activity file.

src/ SlideDownSlideUpAndroidAnimation.java

Android Example: How to Setup Slide Up and Down Animation in Android

Finally we have done all things, run your Slide Down and Slide Up Animation in Android application and click slide up and slide down button, image will start animating.

Post a Comment

Powered by Blogger.