Since FragmentContainerView is a subclass of FrameLayout, a Fragment can be added to it in the same way it can be added to a FrameLayout.Ī FragmentContainerView declaration that uses a tag attribute Adding a Fragment to FragmentContainerView fragment_container_view_tag).Īdding any other views will result in an IllegalStateException being thrown. When FragmentContainerView.addView(View) is called, the view’s tag is retrieved by calling View.getTag(R.id. 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.
0 Comments
Leave a Reply. |