java.lang.IllegalStateException: Cannot start this animator on a detached view!

It's quite tricky to find out the reason of this error. You know what, sometimes it's quite hard to understand that what is going on and where we missed the track. This error comes when there is something wrong with view, which is going to used by animation.

Error :

java.lang.IllegalStateException: Cannot start this animator on a detached view!

Solution :

Yah !!!, so finally here is the solution for this error. Actually the problem is that we are assigning a view to animation with it's height and width, and suddenly we didn't notice that there may be a case, that view won't load properly that time when we are assigning it to animation. So for that we have to wait until view properly loads.

[Your View].post(new Runnable() {
            @Override
            public void run() {
                //Do your animation work here.
            }
        })

Comments