

When a Fragment’s view is being created, a tag is assigned to it in order to associate it with the Fragment instance, this is done by a call to tTag(R.id. Adding a View to FragmentContainerViewįragmentContainerView.addView(view) should only be called with a view that’s associated with a Fragment, this is a View that’s returned by Fragment.onCreateView(LayoutInflater, ViewGroup, boolean). It also supports the attributes, but offers more Fragment transactions flexibility. What is FragmentContainerView?įragmentContainerView is a custom View that extends FrameLayout, but unlike other ViewGroups, it only accepts Fragment Views. This article explains what FragmentContainerView is, how to interact with it, and goes through some of the Fragment animation issues it tackles.


In addition to correctly handling Fragment transactions under the hood, it has some additional features that coordinate with Fragment behavior. FragmentContainerView is now the recommended View to use in order to host Fragments instead of the previously common way of using FrameLayouts.
