Android – How to implement youtube’s UI for a custom app?

kaarthick vicky | 16 xp

I am currently working on a video live streaming app and I would like to implement a UI like Youtube.

Note: I am not going to need Youtube videos.I would like to stream videos from my server.

I did some research and found about this library: Draggablepanel

and tried to add to my project. This is the code for my fragment layout:


and the Java code:

I have an activity called GlobalScreen and that contains a tabview and each tab is a fragment as shown here. I have a fragment called Roomsfragment and there is a recyclerview inside. Clicking on an item should take to the fragment that contains the VLC player to stream the video. With this current implementation I was able to achieve this.

What have I tried so far to get here:

  • First experimented with the Pictureinpicture mode introduced in android oreo. But the method does not seem to work in Android N and below.
  • Next tried to achieve this without draggableview library by adding a framelayout called preview inside the Roomsfragment xml and hid it at the start. For the video screen at first I created an activity and added a fragment there to play the video. I started this activity by using startactivityforresult() method. When i press the backbutton on the video player activity I would come back to the previous screen and in the onActivityResult() i would make the preview layout visible and replace it with the same video fragment. But there was a delay in initializing the vlc player so decided to change it for better UX.
  • Having the UI like Youtube or the bigo live app felt appropriate so used the Draggablepanel library. For this method, I removed the modifications i made in the previous step and used the fragment manager of Globalactivity to replace the fragment on this screen itself. But now when the draggableview minimizes, I am not able to see the previous screen content like Youtube. Not sure how to proceed from here or what other method to implement.