How to make a full-screen dialog with material design?

I tried many options for creating a full-screen dialog, but I could not. I need something like two buttons: http://i.stack.imgur.com/dLSx8.png

+6
source share
3 answers

If you really want the full-screen dialog to simply extend the Dialog class and add a few settings. (You can also accomplish this without expanding anything, but I thought you would want to keep everything in one place)

In your constructor you need to set a style (for your material, or it may be an empty style tag):

 super(context, R.style.DialogStyle); 

you also need to set the view: (Here you define where / what these two buttons are)

 setContentView(R.layout.dialog_view); 

Finally, you may also need to change the window layout options:

 getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT); 

I found on the devices I tested that style setting is the most important.

* EDIT *

To make this clearer, you have two options:

 public class MyDialog extends Dialog { public MyDialog(Context context) { super(context, R.style.YourStyle); setContentView(R.layout.dialog_view); getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT); //Optional //Any other code you want in your constructor } } 

Then, when you want to show it:

 //Inside your activity MyDialog dialog = new MyDialog(this); //Assuming you are in an activity 'this' is your context dialog.show(); 

Or you can simply do this:

 Dialog normalDialog = new Dialog(this, R.style.YourStyle); normalDialog.setContentView(R.layout.dialog_view); normalDialog.show(); 
+3
source

I agree to use the new action. Set the HomeAsUp indicator to whatever you want, then the "Save" button may be the only menu item set to display ifRoom.

http://developer.android.com/reference/android/app/ActionBar.html#setHomeAsUpIndicator(int)

android: showAsAction = ["ifRoom" | "never" | "withText" | "always" | "CollapseActionView"]

0
source

This is what I use to display a complete dialog box without an action bar:

 //Display fullscreen without actionbar if(Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { setStyle(DialogFragment.STYLE_NORMAL, android.R.style.Theme_Holo_Light_NoActionBar_Fullscreen); } else { setStyle(DialogFragment.STYLE_NORMAL, android.R.style.Theme_Material_Light_NoActionBar_Fullscreen); } 
0
source

All Articles