Skip to content
Advertisement

Cannot start this animator on a detached view! reveal effect

I’m trying to create the reveal effect in my application but without success. What i want is reveal a cardview when i open a fragment. What i tried so far is:

JavaScript

and in the onCreateView i started the method:

JavaScript

this is the cardview:

JavaScript

and the logcat:

JavaScript

Checking, seems that getWidth() and getHeight() returns 0. But i don’t know if it’s the real problem. Thanks

Advertisement

Answer

This is how I solved it, I added a onLayoutChange listener to the view in onCreateView callback, so whenever it is attached to the view and ready to draw, it makes the reveal

JavaScript

EDIT: As some people posted, it is better to call toggleInformationView in onViewCreated and avoid the View.OnLayoutChangeListener

Advertisement