Frame Animation in android using Kotlin:

In Frame Animation, several images are framed one by one to show Animation to a human eye.So, for frame animation, we will need the set of images that needs to be framed one by one to show the animation in android.

Steps to use frame animation are given below

First of all add images to the drawable 
Add new resource file
Drawable -> new -> image asset
 new resource file 

Give name it to singal animation

Replace selector with animation list

Write code given below

Write same code for wifi2 wifi3 wifi 4 images
In activity main xml- 
Write code given below

Image view
I’d=@image view
andriod background=”@drawble/signal_animation”

Write code in main activity
This code should be need to write Below set content view
Val signal animation=image view.background as animation drawable
Signal animation.start()
Image view.background=signal animation
Val signal animation=get signal animation()
Signal animation.stop()
In design view add two buttons
One for start
Second for stop
Set constraints for these
In signal animation xml
animation.list xmls: andriod=”http://”>
fun.get signal.animation(): animation.drawable
Valframeone=get drawable.resources(R.drawble.wifi0asbitmapdrwable
Val frametwo=R.drawble.wifi1as Bitmap
Val framethree.R. drawable.wifi2 as bitmap drawable
Val framefour=R.drawable.wifi3 as Bitmap drawable
Val_signal animation=animation drawable
Signal animation.add frame one(frame one,duration200)
Signal animation.add frametwo(frame two,duration 200)
Signal animation.add framethree(frame three,duration 200)
Signal animation.add framefour(frame four,duration 200)
return signal animation

Want to say something? Post a comment

Your email address will not be published. Required fields are marked *