View Animation and Property Animation in Android

  1. View Animation
  2. Property Animation
//Tween animation via xml
Animation animation = AnimationUtils.loadAnimation(getApplicationContext(),

//Tween animaion through AlphaAnimation object. animation = new AlphaAnimation(1,0); animation.setDuration(2000);
Start Animation:
  1. It only works on a View.
  2. you can only animate limited aspects of a view.
  3. it only changes where the view is drawn on the screen but it does not move the view itself.
  1. ViewAnimator: Simple interface for animating view properties. If Need is to animate just one view and don’t want to repeat it, just use ViewPropertyAnimator
.setListener(object : Animator.AnimatorListener {
override fun onAnimationRepeat(animation: Animator) {}
override fun onAnimationEnd(animation: Animator) {}
override fun onAnimationCancel(animation: Animator) {}
override fun onAnimationStart(animation: Animator) {}
.withEndAction({ //API 16+
//do something here where animation ends
// End Action after animation ends   
Runnable endAction = new Runnable() {
public void run() {
// start action before animation starts
withStartAction(new Runnable(){
public void run(){
// do something } });
View.ROTATION_X, 0f, 3600f)
.apply {
duration = 5000
interpolator = AccelerateDecelerateInterpolator()//
repeatCount = INFINITE

mAnimator = ObjectAnimator.ofInt(view, "left", 100,
((mSize.x)/2) - (int) getResources().getDimension(R.dimen.dp_35))
// With object animator, it call setAlpha automatically when the value is calculated.This makes animating any object much easier, as you no longer need to implement the ValueAnimator.AnimatorUpdateListener, because the animated property updates automatically.
FadeIn Animation:
ObjectAnimator animator = ObjectAnimator.ofFloat(mImageView, "alpha", 1f, 0f);
animator.setRepeatCount(1); animator.setRepeatMode(ValueAnimator.REVERSE);
// With value animator, it does not update the value automatically    // It is suitable for object without a set<PropertyName> method    // The example here is for demonstration only    
ValueAnimator animator = ValueAnimator.ofFloat(1f, 0f); animator.setDuration(600);
animator.setRepeatCount(1); animator.setRepeatMode(ValueAnimator.REVERSE);
// We must explicitly listen to update event and set the value animator.removeAllUpdateListeners(); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
public void onAnimationUpdate(ValueAnimator animation)
float alpha = (float)




Android Developer @Bluejeans by Verizon

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Integrate Biometric for existing application

Android Studio學習手冊-layout_constraintVertical_bias, layout_constraintHorizontal_bias

Understanding Streams in Flutter (Dart)

Android 10: No dessert for you

Breaking the ice: Service Locator and Dependency Injection Which is What

Testing Dialogs in Robolectric

Navigation with Dynamic Feature Modules

Avoid these mistakes in pubspec.yaml | Tips for Flutter beginners

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Megha Vaishy

Megha Vaishy

Android Developer @Bluejeans by Verizon

More from Medium

Kotlin development — future of android app development

A Look Into Neverland Casino’s Community Engagement

Game Design Conference (aka GDC) Vault📦 is a thing!

YASAN Launcher: 22.01 Update