ImageView imageView = findViewById(R.id.imageView); Animation animation = AnimationUtils.loadAnimation(this, R.anim.fade_in); imageView.setAnimation(animation);
ImageView imageView = findViewById(R.id.imageView); Animation animation = new ScaleAnimation(0.0f, 1.0f, 0.0f, 1.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); animation.setDuration(1000); imageView.setAnimation(animation);In this example, we are creating a custom ScaleAnimation and setting it to the ImageView. The animation will scale the image from 0 to 1 in both the x and y directions. The animation will last for one second (1000 milliseconds). The android.widget.ImageView class is part of the Android framework and is located in the android.widget package.