My current issue is that I am trying to trigger an Animator to transition between two Activities. My goal is to create a circular reveal transition from one Activity to another.
I am starting to get this error: "Cannot start this animator on a detached view!"
I was looking around Stack Overflow and found this: Cannot start this animator on a detached view! reveal effect
One explanation seems to be that the view for the second Activity has not yet been inflated which is why the Animator is not able to start.
The person in the thread used this as the solution:
@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;
}
However, I'm a little bit confused about what's happening here. It seems that he is also inflating the layout for the Activity. If that's the case, should I not call:
setContentView(R.layout.activity_bnew_account);
in the onCreate method of the Activity? Should I be using the layout inflater in the overridden onCreateView to inflate the activity layout? Thanks for any advice on how to solve this problem.