Home | History | Annotate | Download | only in snackbar
      1 page.title=Showing Pop-Up Messages
      2 page.tags="Snackbar","Toast"
      3 helpoutsWidget=true
      4 trainingnavtop=true
      5 startpage=true
      6 
      7 @jd:body
      8 
      9 <div id="tb-wrapper">
     10 <div id="tb">
     11 
     12 <h2>Dependencies and prerequisites</h2>
     13 <ul>
     14   <li><a href="{@docRoot}tools/support-library/features.html#design">Design
     15     Support Library</a></li>
     16 </ul>
     17 
     18 
     19 <h2>You should also read</h2>
     20 <ul>
     21   <li><a href="{@docRoot}training/implementing-navigation/index.html">
     22     Implementing Effective Navigation</a></li>
     23   <li><a href="https://www.google.com/design/spec/components/snackbars-toasts.html">
     24     Material Design: Snackbars &amp; toasts</a></li>
     25 </ul>
     26 
     27 </div>
     28 </div>
     29 
     30 <p>
     31   There are many situations where you might want your app to show a quick
     32   message to the user, without necessarily waiting for the user to respond.
     33   For example, when a user performs an action like sending an email or deleting
     34   a file, your app should show a quick confirmation to the user. Often the user
     35   doesn't need to respond to the message. The message needs to be prominent
     36   enough that the user can see it, but not so prominent that it prevents the
     37   user from working with your app.
     38 </p>
     39 
     40 <p>
     41   Android provides the {@link android.support.design.widget.Snackbar} widget
     42   for this common use case.
     43   A {@link android.support.design.widget.Snackbar} provides a quick pop-up
     44   message to the user. The current activity remains visible and interactive
     45   while the {@link android.support.design.widget.Snackbar} is displayed. After a
     46   short time, the Snackbar automatically dismisses itself.
     47 </p>
     48 
     49 <p>
     50   This class teaches you how to use {@link
     51   android.support.design.widget.Snackbar} to show pop-up messages.
     52 </p>
     53 
     54 <div class="figure" style="width:400px">
     55   <img src="{@docRoot}images/training/snackbar/snackbar_drive_2x.png"
     56     srcset="{@docRoot}images/training/snackbar/snackbar_drive.png 1x,
     57         {@docRoot}images/training/snackbar/snackbar_drive_2x.png 2x"
     58     width="400" alt="">
     59   <p class="img-caption">
     60     <strong>Figure 1.</strong> A {@link android.support.design.widget.Snackbar}
     61     shows a message at the bottom of the
     62     activity, but the rest of the activity is still usable.
     63   </p>
     64 </div>
     65 
     66 <p class="note">
     67   <strong>Note:</strong> The {@link
     68   android.support.design.widget.Snackbar} class supersedes {@link
     69   android.widget.Toast}. While {@link android.widget.Toast} is currently still
     70   supported, {@link android.support.design.widget.Snackbar} is now the
     71   preferred way to display brief, transient messages to the user.
     72 </p>
     73 
     74 <h2>Lessons</h2>
     75 
     76 <dl>
     77   <dt>
     78     <b><a href="showing.html">Using a Snackbar to Show a Message</a></b>
     79   </dt>
     80 
     81   <dd>
     82     Learn how to use a {@link android.support.design.widget.Snackbar} to display
     83     a brief message to the user.
     84   </dd>
     85 
     86   <dt>
     87     <b><a href="action.html">Adding an Action to a Message</a></b>
     88   </dt>
     89 
     90   <dd>
     91     Learn how to add an action to a message, allowing the user to respond to
     92     the message.
     93   </dd>
     94 </dl>
     95