Search code examples
androidandroid-animationandroid-6.0-marshmallowfadein

Fade in Animation not working in Android M


I am developing in Android application in that I am using fade-in animation.

So it's working in below Android version (Kitkat, Lolipop, etc.) but when I tried to run in Android Marshmallow its not working.

I am using below code for fade-in animation:

<?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:fillAfter="true"
        android:duration="2000"/>
</set>

Note: I am using Samsung Galaxy J7 device for test.

Solution:

After adding below line issue solved.

android:interpolator="@android:anim/linear_interpolator"

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:interpolator="@android:anim/linear_interpolator">
    <alpha
        android:duration="2000"
        android:fillAfter="true"
        android:fromAlpha="0.0"
        android:toAlpha="1.0" />
</set>

Solution

  • You are not using Interpolator property of "set" tag. here is a good example of fade in and fade out animation.

    http://android-er.blogspot.in/2012/02/animate-fade-infade-out-by-changing.html

    Thanks