It doesn’t look like this however, which leads us to the problem. For reference, if the NewFragment was not added on top of our `MainFragment,` but rather existed on its own, it would look like this: The NewFragment plays an animated video instead of a regular video to better illustrate the issue. Just like in MainFragment, in `onViewCreated` the NewFragment finds a reference it its VideoView and begins playing it. The NewFragment instantiates a layout very similar to MainFragment except it has a colored background and an offset VideoView so that it only partially overlaps with the VideoView from MainFragment: In the sample project clicking the FAB will execute the following Fragment transaction: getSupportFragmentManager().beginTransaction().add(R.id.content_layout, NewFragment.newInstance()).commit() Next up, we simply need to add another Fragment that contains a VideoView to the `content_layout` container, the same container holding our MainFragment. Here is what the MainFragment looks like: Uri video = Uri.parse("android.resource://" + getContext().getPackageName() + "/" + R.raw.video) tMediaController(new MediaController(getContext())) videoView = (VideoView) view.findViewById(R.id.video_view) `onViewCreated` in `MainFragment` will setup the VideoView and begin playing the sample video. In the `onCreate` of the Activity, the `MainFragment` is added: getSupportFragmentManager().beginTransaction().add(R.id.content_layout, MainFragment.newInstance(), "MAIN_FRAGMENT").commit()
There is no need to download the sample project as the code snippets below will be enough explanation.
I have reported the issue and though I probably wouldn’t consider this a bug in the Android framework, I would consider it unexpected behavior. I have created a sample project here which shows the issue and where the code snippets below will be taken from. This however, is not the case when it comes to VideoViews, which require you to call `tZOrderMediaOverlay(true)` on the VideoView you would like to appear on top. As is the case with most Views, when adding a Fragment on top of another, the top Fragment will have its Views drawn on top of the bottom Fragment.
Recently, in a client project, I ran into an issue with VideoViews overlapping each other, even though they were part of different Fragments.