Step by step tutorial how to create Animations: zoom, clockwise, fade, slide, move, blink on Android Studio 4.1.3.
Follow video tutorial:
Create new project with Application name: My animations.
In app->res-> create New Directory: anim.
In app->res-> drawable drag and drop a picture: pic.png
In app->java->MainActivity.java write the code:
package com.example.toyo.myanimations
import android.app.Activity
import android.os.Bundle
import android.view.View
import android.view.animation.AnimationUtils
import android.widget.ImageView
class MainActivity : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
}
fun clockwise(view: View?) {
val image = findViewById<View>(R.id.imageView) as ImageView
val animation = AnimationUtils.loadAnimation(applicationContext,
R.anim.zoom)
image.startAnimation(animation)
}
fun zoom(view: View?) {
val image = findViewById<View>(R.id.imageView) as ImageView
val animation1 = AnimationUtils.loadAnimation(applicationContext,
R.anim.clockwise)
image.startAnimation(animation1)
}
fun fade(view: View?) {
val image = findViewById<View>(R.id.imageView) as ImageView
val animation1 = AnimationUtils.loadAnimation(applicationContext,
R.anim.fade)
image.startAnimation(animation1)
}
fun slide(view: View?) {
val image = findViewById<View>(R.id.imageView) as ImageView
val animation1 = AnimationUtils.loadAnimation(applicationContext, R.anim.slide)
image.startAnimation(animation1)
}
fun move(view: View?) {
val image = findViewById<View>(R.id.imageView) as ImageView
val animation1 = AnimationUtils.loadAnimation(applicationContext, R.anim.move)
image.startAnimation(animation1)
}
fun blink(view: View?) {
val image = findViewById<View>(R.id.imageView) as ImageView
val animation1 = AnimationUtils.loadAnimation(applicationContext,
R.anim.blink)
image.startAnimation(animation1)
}
}
In app->res->layout->activity_main.xml write the code:
Leave a Reply