You really don't need to use dialogue. I think that dialogs are more appropriate if you want to show simple presentations or just an alert / confirmation to the user (usually this is done using AlertDialog).
In your situation, I think the best approach would be to have a FrameLayout in your activity, a sibling of your main layout and add a snippet to it when you want to show a popup similar to this main activity layout. As long as you place the fragment view after the root activity layout element, the fragment will appear on top of your main layout as an overlay. eg:.
<merge xmlns:android="http://schemas.android.com/apk/res/android"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> </LinearLayout> <FrameLayout android:id="@+id/overlay_fragment_container" android:layout_width="match_parent" android:layout_height="match_parent"/> </merge>
and then in your activity, when you want to display the fragment that you are doing:
FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction() .add(R.id.overlay_fragment_container, yourFragment) .commit();
Hope this helps :) Good luck!
source share