Cannot start this animator on a detached view! reveal effect

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

@Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
    {
        // Inflate the layout for this fragment
        final View view = inflater.inflate(R.layout.fragment_map_list, container, false);
        if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            view.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
                @TargetApi(Build.VERSION_CODES.LOLLIPOP)
                @Override
                public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
                    v.removeOnLayoutChangeListener(this);
                    toggleInformationView(view);
                }
            });
        }
        return view;
    }

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


You can use runnable to do the anim . The runnable will run after the view's creation .

view.post(new Runnable() {
            @Override
            public void run() {
                //create your anim here
            }
        });