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
148
votes
9 answers

Android - Snackbar vs Toast - usage and difference

We have been using just Toasts in our application so far and as we are planning to adopt some new features from Support Design Library I am wondering what's the recommended usage for Snackbar vs. Toast. I have been reading on the google material…
Jakub Holovsky
  • 6,543
  • 10
  • 54
  • 98
129
votes
11 answers

How to show Snackbar when Activity starts?

I want to show android Snackbar (android.support.design.widget.Snackbar) when the activity starts just like we show a Toast. But the problem is we have to specify the parent layout when creating Snackbar like this: Snackbar.make(parentlayout, "This…
Sudheesh Mohan
  • 2,560
  • 3
  • 21
  • 38
123
votes
21 answers

How to change background color of the snackbar?

I am showing snackbar in a DialogFragment within the positive touch of the alert dialog. Here is my code snippet: Snackbar snackbar = Snackbar.make(view, "Please enter customer name", Snackbar.LENGTH_LONG) .setAction("Action",…
110
votes
12 answers

how to customize snackBar's layout?

Is there any method to change the layout of a snackBar to custom View? Now it comes black and we can change the background color. But I don't know the right way to inflate a new layout and making it as snackBars background? Thanks...
110
votes
13 answers

How can I be notified when a Snackbar has dismissed itself?

I'm using a Snackbar from the com.android.support:design:22.2.0 library. I'm using it to undo deletions. To make my life easier, I'm going to make the UI look like things are actually deleted from the data source, and if the undo button in the snack…
108
votes
8 answers

How to dismiss a Snackbar using its own Action button?

Android design support library now includes support for Snackbar. I've used the following code to create one: Snackbar.make(findViewById(R.id.root_layout), result, Snackbar.LENGTH_LONG) .setAction("Dismiss", new View.OnClickListener() { …
Asim
  • 6,962
  • 8
  • 38
  • 61
105
votes
20 answers

Android Multiline Snackbar

I'm trying to leverage new Snackbar from Android Design Support Library to display multiline snackbar, as shown in http://www.google.com/design/spec/components/snackbars-toasts.html#snackbars-toasts-specs: import…
104
votes
24 answers

How to set support library snackbar text color to something other than android:textColor?

So I've started using the new Snackbar in the Design Support Library, but I found that when you define "android:textColor" in your theme, it applies to the text color of the snackbar. This is obviously a problem if your primary text color is…
96
votes
5 answers

Can't resolve android.support.design. after migration to AndroidX

I am trying to get the TextView of the Snackbar with this code snippet: snackbarView.findViewById(android.support.design.R.id.snackbar_text) but Android Studio does not resolve the design library. How can I get this code to work?
dudi
  • 5,523
  • 4
  • 28
  • 57
81
votes
20 answers

Display SnackBar in Flutter

I want to display a simple SnackBar inside Flutter's Stateful widget. My application creates new instance of MaterialApp with a stateful widget called MyHomePage. I try to show the SnackBar in showSnackBar() method. But it fails with The method…
81
votes
11 answers

Show Android SnackBar above keyboard?

Is it possible to show the Android Snackbar above the keyboard (as in Y coordinate, not layering)? The Snackbar currently gets hidden if the keyboard is shown, which is an undesirable behavior.
fobbymaster
  • 1,406
  • 3
  • 14
  • 22
76
votes
13 answers

Move snackbar above the bottom bar

I am facing some problems with new bottom bar. I can't force to move the snackbar above the bottom bar (this is how design guideline told me should be…
Wladislaw
  • 1,200
  • 2
  • 12
  • 23
60
votes
10 answers

Making a Snackbar Without a View?

I want to show a snackbar as soon as the user opens the Google Maps activity, but the thing is that there's no views in the activity to use as the first parameter of the activity (in the findViewById() of Snackbar.make()). What do I put…
Kelvin Kellner
  • 746
  • 1
  • 6
  • 15
59
votes
4 answers

Snackbar is not working within fragment class

I am trying to show snackbar view when I click on button but it shows force close error when I click on button I have define fragment class below and also error log. I have fragment class: public class HomeFragment extends Fragment { …
54
votes
12 answers

How to show Snackbar at top of the screen

As the Android documentation says 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. Is there any alternative by which we can show snackbars…
Pankaj
  • 7,908
  • 6
  • 42
  • 65
1
2 3
31 32