Questions tagged [android-snackbar]

Snackbars provide lightweight feedback about an operation. They show a brief message at the bottom of the screen on mobile and lower left on larger devices. Snackbars appear above all other elements on screen and only one can be displayed at a time.

Introduction

Snackbars provide lightweight feedback about an operation. They show a brief message at the bottom of the screen on mobile and lower left on larger devices. Snackbars appear above all other elements on screen and only one can be displayed at a time.

They automatically disappear after a timeout or after user interaction elsewhere on the screen, particularly after interactions that summon a new surface or activity. Snackbars can be swiped off screen.

Snackbars can contain an action which is set via setAction(CharSequence, android.view.View.OnClickListener).

Documentation

Usage of SnackBar

477 questions
24
votes
3 answers

Is it a good practice to wrap all layouts in CoordinatorLayout?

I'm thinking of a way to implement Android Snackbars in my app. Basically, I want to be able to show Snackbar from anywhere in the app. As I found out, android.support.design.widget.Snackbar performs the best when put in…
23
votes
2 answers

What is the actual duration of a Snackbar with LENGTH_LONG

Since I've migrated my Android Project to AndroidX i am receiving the following lint error: Error: Must be one of: Snackbar.LENGTH_INDEFINITE, Snackbar.LENGTH_SHORT, Snackbar.LENGTH_LONG [WrongConstant] Snackbar snackbar =…
ice_chrysler
  • 2,633
  • 1
  • 21
  • 27
22
votes
2 answers

Android: MVVM is it possible to display a message (toast/snackbar etc.) from the ViewModel

I want to know what is the best approach to display some sort of message in the view from the ViewModel. My ViewModel is making a POST call and "onResult" I want to pop up a message to the user containing a certain message. This is my…
user3182266
  • 1,270
  • 4
  • 23
  • 49
22
votes
4 answers

Snackbar is not dismissing on swipe

i have a snackbar in my appcompat activity. It has a button OK which dismiss the snackbar.It is working perfact. but i can't dismiss the snackbar on swipe(left to right). Following is my code for snackbar.... final Snackbar snackbar = Snackbar …
Intimate
  • 446
  • 2
  • 5
  • 18
22
votes
5 answers

when is Snackbar isQueued () used? (How to queue the snackbar)

If i call the snackbar multiple times in a row, only the last snackbar item is displayed. e.g. with the codes below, only Item 3 would be shown. it seems that Snackbar.LENGTH_LONG is ignored (and set to zero?) for item 1 and 2. Snackbar.make(view,…
Angel Koh
  • 12,479
  • 7
  • 64
  • 91
21
votes
10 answers

Changing typeface of Snackbar

I build Snackbar by this code: Snackbar sb = Snackbar.make(drawer, "message", Snackbar.LENGTH_LONG) .setAction("action", new View.OnClickListener() { @Override public void onClick(View view) { } }); Now I want to…
user5510211
  • 297
  • 1
  • 3
  • 13
21
votes
3 answers

SnackBar and fitsSystemWindow

I have an app that uses fitsSystemWindows to be able to draw an background behind Navigation- and Status-Bar - unfortunately the SnackBar seems to ignore the fitsSystemWindows=true from the container. I boiled the problem down to this minimal…
ligi
  • 39,001
  • 44
  • 144
  • 244
20
votes
7 answers

Snackbar in Support Library doesn't include OnDismissListener()?

I'd like to implement the new Snackbar included in the latest Design Support Library, but the way it is offered seems counter-intuitive for my, and I assume many others', use. When the user does an important action, I want to allow them to undo it…
19
votes
8 answers

How to disable snackbar's swipe-to-dismiss behavior

Is there a way to prevent the user from dismissing a snackbar by swiping on it? I have an app that shows a snack bar during network login, I want to avoid it to be dismissed. According to Nikola Despotoski suggestion I've experimented both…
Paolone
  • 475
  • 1
  • 7
  • 16
18
votes
3 answers

How does calling Snackbar.make() from non-UI thread work?

I can call Snackbar.make() from a background thread without any problems. This is surprising to me since I thought UI operations are only allowed from the UI thread. But that is definitely not the case here. What exactly makes Snackbar.make()…
q126y
  • 1,589
  • 4
  • 18
  • 50
18
votes
4 answers

Floating Action Button is not going up when snack bar is display a message in android

I am Using Snack bar and FAB in my application Same Page,Whenever Snackbar is Showing Floating Action button not Going up. I am Using Third Party library for attachToListView works fine import com.melnykov.fab.FloatingActionButton; if I am…
Kumar
  • 969
  • 2
  • 22
  • 56
17
votes
4 answers

Dismiss Snackbar On left swipe

Simple code below for showing the Snackbar. public void onClick(View view) { Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_INDEFINITE) .setAction("Action", null).show(); } This code correctly shows the…
AADProgramming
  • 6,077
  • 11
  • 38
  • 58
16
votes
3 answers

How do you implement the snackbar that has the button at the bottom?

On the material design specs there is a snackbar that has the button at the bottom. How do you implement that? Here is the image from the spec. I'm talking about the last one.
16
votes
6 answers

Show a SnackBar on the top (below of the toolbar)

I'm trying to show a SnackBar on top below of the ToolBar in my MainActivity, I've tried this code : mToolbar = (Toolbar) findViewById(R.id.toolbar); Snackbar snack = Snackbar.make(findViewById(android.R.id.content), "Had a snack at Snackbar",…
Stranger B.
  • 9,004
  • 21
  • 71
  • 108
15
votes
4 answers

Can I display material design Snackbar in dialog?

I am developing an android application. In that I want to display material design Snackbar in dialog. Is it possible? If yes then how? Please help me. Thanks.
Ganpat Kaliya
  • 888
  • 2
  • 9
  • 16
1 2
3
31 32