You can use ConstraintLayoutto contain Fragment. It can also be a base view Fragment. However, I usually use it FrameLayoutas a holder, because in most cases there is no reason to use a complex layout, for example ConstraintLayout.
As you can see, it FragmentTransaction.add()does not set limits for containerViewId View.
public abstract FragmentTransaction add(@IdRes int containerViewId, Fragment fragment, String tag);
Similarly, it Fragment.onCreateView()can return any view:
@Nullable
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState)
source
share