Using fade in animation for a view

Suppose you have an ImageView named imageView and an animation file your_fade_in_anim.xml inside your res\anim\ folder:

ImageView imageView = (ImageView) findViewById(R.id.imageView);
Animation fadeInAnimation = AnimationUtils.loadAnimation(this, R.anim.your_fade_in_anim);
// Now Set your animation
imageView.startAnimation(fadeInAnimation);

Your XML

<?xml version="1.0" encoding="UTF-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <alpha 
        android:fromAlpha="0.0"
        android:toAlpha="1.0" 
        android:interpolator="@android:anim/accelerate_interpolator" 
        android:duration="[duration (in milliseconds)]"
        android:repeatCount="infinite" />
</set>

Replace the brackets with your actual duration.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)