0

In Android I can display short messages to the user either using Toasts or Snackbars.

Is there a particular standard as to which ones I should be using? All Toasts? All Snackbars? Toasts during DialogFragments and Snackbars otherwise? Is there a way to force a Snackbar to display on "top" of the rest of the screen (in the event that I don't want to pass a specific view to it)?

AJJ
  • 2,004
  • 4
  • 28
  • 42

2 Answers2

0

Snackbar it's material feature, Toast - holo style. If your application has material design, more better use Snackbar as material item(like physical peace of paper) instead semitransparent/shadowed Toast. In comparison to real world:

How often do you see "text in air"? Newer)) But may be when you under some drugs it possible) Ghost is unreal) Due to material world, texts on papers, boards, another physical places is normal behavior.

In case of upper snack, discover this

Community
  • 1
  • 1
once2go
  • 1,452
  • 1
  • 13
  • 21
  • Does an "upper snack" also work when you're using DialogFragments? – AJJ Jun 10 '16 at 14:35
  • I have to also say, even though I have read the Material Design spec pages, I still have no real idea what it means to use Material Design. Shadows implying elevations and different items, I guess? – AJJ Jun 10 '16 at 14:36
  • It's depends on your fragment. If it full screen, it take place. By the way, dialog is another material/physical entity – once2go Jun 10 '16 at 14:38
  • I would imagine everything on the screen is a material entity in some form – AJJ Jun 10 '16 at 14:40
  • What you would show in snack/toast due to your flow? – once2go Jun 10 '16 at 14:43
  • Usually in two main cases: Improper input (field is blank, something already exists with that name/timestamp in the database, etc), or some kind of operation is carried out (changes saved, updated, refreshed, etc) – AJJ Jun 10 '16 at 14:44
  • http://stackoverflow.com/a/30953551/3612976 good reference for blank field if empty or with error. In case of non input message, use snack, bat i really cant understand this "work when you're using DialogFragments?", seams to me it's UX overhead, to us both attention messages at same time. – once2go Jun 10 '16 at 15:00
  • What about using EditText.setError()? Does this clash with Material Design guidelines? – AJJ Jun 10 '16 at 15:15
  • Don't know exactly, suppose it's ok. – once2go Jun 10 '16 at 15:31
0

If you want to confirm to the user that something just happened, that something went ok etc. a Toast is the way to go I would say.

But if the user did something like for example removed an item from a list, you would want to give the user an option to Undo. It could probably be done with an alert dialog but that's also annoying for the user. To be forced to change focus and act to an alert dialog asking if it's really what the user wants to do, for example "Do you really want to delete that? No Yes".

With a SnackBar you can inform the user that the item was deleted but also provide an Undo-action. Which should put back the item into the list on click.

Look at this short video, she explains the usage of those better :)

https://www.youtube.com/watch?v=puhfMX8jb9c&list=PLWz5rJ2EKKc-lJo_RGGXL2Psr8vVCTWjM&index=5

malmling
  • 2,398
  • 4
  • 19
  • 33
  • What if the user is in the middle of a DialogFragment (e.g. "enter your name/age/whatever" and the user provides a blank name -- so you'd want a message telling them to enter something). How would you inform the user when everything outside of the DialogFragment is darkened? – AJJ Jun 10 '16 at 14:35
  • 1
    For errors in a form of input fields you should probably do something according to googles material design guidelines. Validating the fields and if there is errors display a informal text below the input field. Like this https://material.google.com/patterns/errors.html#errors-usage – malmling Jun 10 '16 at 14:37
  • Oh wow that's a great idea... can't believe I didn't think of that. Seems so obvious in hindsight! – AJJ Jun 10 '16 at 14:45