How to manage full-screen dialogs in Android?

I am thinking about the appearance of dialog boxes. Quoting design rules :

Due to the limited real estate on mobile devices, content that can be displayed as a dialogue in other form factors (tablet, desktop, etc.). more adequately presented in a full-screen dialog box.

And that seems reasonable to me. This section also introduces the Dialog dialog as built-in / full-screen, depending on the screen size. Basically, you can:

  • for small screens, override public Dialog onCreateDialog() in DialogFragment and call .show() ;
  • for wide screens, override also public View onCreateView() and commit the fragment transaction.

I approached this as an easy task, but I have some problems with the concept of a full-screen dialog and how to manage them. I'm not even sure that the design guide in the full-screen dialog is indeed DialogFragment .

For example, in pic, I linked the full screen dialog to the toolbar.

In full-screen dialogs, confirm and neglect actions at the top of the screen.

The toolbar style for full-screen dialogs is rather strange: X for rejection, name, confirmation of action on the right. These elements are a full-screen version of the elements in the floating AlertDialog , nothing new here.

What is interesting to me - do I have to deal with these actions twice, once for the floating and once for the full-screen version? Should I customize both versions of the dialog box?

Also, where does this toolbar come from? Should we load the dialog fragment in android.R.id.content and add the Toolbar inside the fragment? Should we load it into the actual activity layout and redo the toolbar at runtime? Should we handle the dialog fragment as Dialog and show() it with the specific attributes of the window (but then by removing the buttons at the bottom and adding the toolbar.)?

I thought this process was automatically controlled by the DialogFragment class, but it doesn’t look like that.

+5
source share

Source: https://habr.com/ru/post/1212556/


All Articles