How to show Snackbar at top of the screen

It is possible to make the snackbar appear on top of the screen using this: Snackbar snack = Snackbar.make(parentLayout, str, Snackbar.LENGTH_LONG); View view = snack.getView(); FrameLayout.LayoutParams params =(FrameLayout.LayoutParams)view.getLayoutParams(); params.gravity = Gravity.TOP; view.setLayoutParams(params); snack.show(); From the OP: I had to change the first line: Snackbar snack = Snackbar.make(findViewById(android.R.id.content), “Had a snack at Snackbar”, Snackbar.LENGTH_LONG);

Making a Snackbar Without a View?

I see some options… Not sure which one can fix your issue. Simpliest SupportMapFragment extends class android.support.v4.app.Fragment. This way, it has a method getView() Snackbar.make(mapFragment.getView(), “Click the pin for more options”, Snackbar.LENGTH_LONG).show(); Find Root View From this answer, there’s a way to get the root view via: getWindow().getDecorView().getRootView() So, maybe, you can do: Snackbar.make(getWindow().getDecorView().getRootView(), “Click … 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

Android Multiline Snackbar

Just set the maxLines attribute of Snackbars Textview View snackbarView = snackbar.getView(); TextView textView = (TextView) snackbarView.findViewById(android.support.design.R.id.snackbar_text); textView.setMaxLines(5); // show multiple line If you’re using the more recent “com.google.android.material:material:1.0.0″dependency, then you will use this: com.google.android.material.R.id.snackbar_text to access the Snackbar’s TextView. You can use even R.id.snackbar_text as well. it’s work for me.

How to dismiss a Snackbar using it’s own Action button?

For Java, The .make method returns a Snackbar object. Save an instance of that object by making it final. Then, in the onClick(), call .dismiss: final Snackbar snackBar = Snackbar.make(findViewById(android.R.id.content), “Snackbar Message”, Snackbar.LENGTH_LONG); snackBar.setAction(“Action Message”, new View.OnClickListener() { @Override public void onClick(View v) { // Call your action method here snackBar.dismiss(); } }); snackBar.show(); For … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)