snackbar
Can we perform 2 different actions in Snack bar at a time in android?
From the Google design specifications: Each snackbar may contain a single action, neither of which may be “Dismiss” or “Cancel.” For multiple actions, use a dialog.
How can you adjust Android SnackBar to a specific position on screen
It is possible to set the location that the Snackbar is displayed by positioning a android.support.design.widget.CoordinatorLayout within your existing Activity layout. For example, say your existing layout is a RelativeLayout you could add a CoordinatorLayout as follows: <android.support.design.widget.CoordinatorLayout android:layout_width=”match_parent” android:layout_height=”200dp” android:id=”@+id/myCoordinatorLayout” android:layout_alignParentTop=”true” android:layout_alignParentLeft=”true” android:layout_alignParentStart=”true”> </android.support.design.widget.CoordinatorLayout> Then, make sure you pass the CoordinatorLayout as the first … Read more
Flutter snackbar dismiss on SnackBarAction onPressed
You can also use, Scaffold.of(context).hideCurrentSnackBar(); Be careful when you use context, use the correct context. NOTE In the new Flutter Version, this method is deprecated. Therefore use ScaffoldMessenger.of(context).hideCurrentSnackBar();
How to use setDuration() method in SnackBar (Android Design Support Library)
Based on the implementation of Snackbar and SnackbarManager, I can confirm Eugene H’s assessment: it’s a bug. From SnackbarManager: private void scheduleTimeoutLocked(SnackbarRecord r) { mHandler.removeCallbacksAndMessages(r); mHandler.sendMessageDelayed(Message.obtain(mHandler, MSG_TIMEOUT, r), r.duration == Snackbar.LENGTH_LONG ? LONG_DURATION_MS : SHORT_DURATION_MS); } So, any value that is not LENGTH_LONG results in a short-duration snackbar. I have filed an issue about it. … Read more
Move snackbar above the bottom bar
With the material components library you can use the setAnchorView method to make a Snackbar appear above a specific view. In your case if you are using a BottomAppBar and a fab, you should define the fab in the setAanchorView. Something like: FloatingActionButton fab = findViewById(R.id.fab); Snackbar snackbar = Snackbar.make(view, “Snackbar over BottomAppBar”, Snackbar.LENGTH_LONG); snackbar.setAnchorView(fab); … Read more
Display SnackBar in Flutter
In my case i had code like this (in class state) final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>(); void showInSnackBar(String value) { _scaffoldKey.currentState.showSnackBar(new SnackBar(content: new Text(value))); } but i didn’t setup the key for scaffold. so when i add key: _scaffoldKey @override Widget build(BuildContext context) { return new Scaffold( key: _scaffoldKey, body: new SafeArea( snackbar start … Read more
How to set support library snackbar text color to something other than android:textColor?
I found this at What are the new features of Android Design Support Library and how to use its Snackbar? This worked for me for changing the text color in a Snackbar. Snackbar snack = Snackbar.make(view, R.string.message, Snackbar.LENGTH_LONG); View view = snack.getView(); TextView tv = (TextView) view.findViewById(android.support.design.R.id.snackbar_text); tv.setTextColor(Color.WHITE); snack.show(); UPDATE: ANDROIDX: As dblackker points out … Read more
How can I be notified when a Snackbar has dismissed itself?
Google design library supports Snackbar callbacks in version 23. See Snackbar docs and Callback docs. You will then get notified when the Snackbar gets dismissed (and also when shown) and also the type of dismissal if this is useful for you: snackbar.addCallback(new Snackbar.Callback() { @Override public void onDismissed(Snackbar snackbar, int event) { //see Snackbar.Callback docs … Read more
how to customize snackBar’s layout?
The Snackbar does not allow you to set a custom layout. However, as Primoz990 suggested you can get the Snackbar’s View. The getView function returns the Snackbar.SnackbarLayout, which is a horizontal LinearLayout object whose children are a TextView and a Button. To add your own View to the Snackbar, you just need to hide the … Read more