DialogFragment dialog fill screen

I am using DialogFragment and would like to know if there is an easy way to specify a dialog for using full-screen mode on a regular / small device (phone). An example of what I want to achieve is a confirmation / permission dialog box that appears on Google Play after you select Install Application.

enter image description here

+4
source share
3 answers

If you want to fill the screen with the DialogFragment dialog box, you can simply change the theme. Use for full-screen android.R.style.Theme_Holo_Light and for non-full-screen dialogs use android.R.style.Theme_Holo_Light_Dialog;

Use these values ​​in the call:

setStyle (DialogFragment.STYLE_NO_TITLE, android.R.style.Theme_Holo_Dialog); // as an example

I call this method at the end of onCreate ().

Hope this helps Jasper

+6
source

On your tablet, display the dialog in the usual way.

DialogFragment newFragment = MyDialogFragment.newInstance(); newFragment.show(getFragmentManager(), "dialog"); 

On the phone, add DialogFragment to the layout as a regular fragment in Activity onCreate ().

 @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); if (savedInstanceState == null) { FragmentTransaction ft = getFragmentManager().beginTransaction(); DialogFragment newFragment = MyDialogFragment.newInstance(); ft.add(R.id.embedded, newFragment); ft.commit(); } 

activity_main.xml

 <?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/embedded" android:layout_width="match_parent" android:layout_height="match_parent"> </FrameLayout> 

Note. Tag embedded snippet

+2
source

There was the same question (with an exact diagram!) And the answer (the one who asked him). The answer is valid, also using the category of resource directories. Dialog box embedding is device dependent

0
source

All Articles