

Once we create an application, open activity_main.xml file from \res\layout folder path and write the code like as shown below. In case if you are not aware of creating an app in android studio check this article Android Hello World App. Android Slide Up & Slide Down Animations Exampleįollowing is the example of implementing a slide up and slide down animations to slide an image up or down on button click in android applications.Ĭreate a new android application using android studio and give names as SlideUpDownExample. Now we will see how to implement slide up and slide down animations for imageview on button click in android applications with examples. Here we used another method startAnimation() to apply the defined animation to imageview object.

The second parameter in loadAnimation() method is the name of our animation xml file. If you observe above code snippet, we are adding an animation to the image using loadAnimation() method. imgvw ) Īnimation aniSlide = AnimationUtils.loadAnimation(getApplicationContext(),R.anim. ImageView img = (ImageView)findViewById(R.id. To use Slide Up or Slide Down animations in our android applications, we need to define a new XML file with tag like as shown below.įor Slide Up animation, we need to set android :fromYScale= "1.0" and android :toYScale= "0.0" like as shown below. In case, if anim folder does not exist in res directory, create a new one. We need to create an XML file that defines the type of animation to perform in a new folder anim under res directory ( res à anim à slide_up.xml) with the required properties. To create an animation effect to the objects in our android application, we need to follow below steps.

Generally, the animations are useful when we want to notify users about the change’s happening in our app, such as new content loaded or new actions available, etc. The Slide Up and Slide Down animations will provide a better look and feel for our applications. In android, Slide Up and Slide Down animations are used to change the appearance and behavior of the objects over a particular interval of time.
