Search code examples
androidpopupfragmentandroid-dialogfragment

Popup window using Fragment


I want to create a pop-up window (with black transparent background around it) that would appear above the application activity screen (by clicking on a button). This pop-up would contain a video player, a list of videos to be played and some other elements. This pop-up has to be a fragment since I need to re-use it from other app fragments.

So my question is : what is the best way to achieve that? I personally see 2 options :

1) adding the pop-up as a fragment on the layout and to show + activate it whenever I need. But in that case, how can I put a black transparent background around it that would fill the whole screen?

2) using DialogFragment but it seems that this class is not very well-designed for this kind of stuff.

What do you think?

Thanks in advance.


Solution

  • DialogFragments are the suggested way to launch Dialog views from within a Fragment, so this is the solution I would suggest for you.

    You can do pretty much anything you need within the DialogFragment. You will be in full control of the UI using this method.

    Here is a SO discussion of the same point, with good info: Android DialogFragment vs Dialog