android-snackbar

Add margins to Snackbar view

瘦欲@ 提交于 2019-11-28 13:36:13
I'm updating my current app to use snackbars, in the Google spec they show various ways of using them http://www.google.com/design/spec/components/snackbars-toasts.html#snackbars-toasts-specs Example A: Example B: Here's my code atm: Snackbar snackbar = Snackbar.make(mParentLayout, displayMessage, Snackbar.LENGTH_LONG); snackbar.setAction(actionMessage, mClickListener); snackbar.show(); I get the result in Example B, How can i add margins? In addition to Saeid's answer, you can get the default SnackBar layout params and modify them as you want: public static void

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

↘锁芯ラ 提交于 2019-11-27 22:20:17
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 solutions: private void startSnack(){ loadingSnack = Snackbar.make(findViewById(R.id.email_login_form), getString(R.string.logging_in), Snackbar.LENGTH_INDEFINITE) .setAction("CANCEL", new OnClickListener() { @Override public void onClick(View view) { getOps().cancelLogin(); enableControls(); } }); loadingSnack.getView().setOnTouchListener(new View

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

梦想与她 提交于 2019-11-27 17:56:42
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 bar is not pressed, actually perform the deletions from the data source. So, I want to know when the Snackbar is no longer visible, so it's safe to delete the items. I can call getView() on the Snackbar, but I'm not sure what listener I should be using. I tried setOnSystemUiVisibilityChangeListener() but that didn't work, I believe it is only for

How can you adjust Android SnackBar to a specific position on screen

此生再无相见时 提交于 2019-11-27 14:48:31
问题 Follwing the new android snackbar, i'm trying to set it to be positioned on a specific y coordinate. Its seems to be not even a possible. I've tried with getting the parent of the snackbar's view, but, there's nothing to be done to the parent for it to set the position of it. mSnackBar.getView().getParent(); When digging into the actual class, there's an instance of mView, and mParent which is private, and can't be reached anyhow. https://developer.android.com/reference/android/support/design

Display SnackBar in Flutter

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-27 13:32:53
问题 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 'showSnackBar' was called on null '. What's wrong with this code? class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return new MaterialApp( title: 'Flutter', theme: new ThemeData( primarySwatch: Colors.blue, ),

Snackbar is not working within fragment class

放肆的年华 提交于 2019-11-27 13:25:00
问题 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 { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_home, container, false); context = getActivity(); initUI(rootView); return rootView; } private void

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

守給你的承諾、 提交于 2019-11-27 11:01:43
问题 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() { @Override public void onClick(View v) { } }).show(); The snackbar can be dismissed by a swipe. However, I also want to dismiss it using its own Action Button (created using the setAction function). However there doesn't seem to be any function available that

How to show Snackbar at top of the screen

假装没事ソ 提交于 2019-11-27 10:53:48
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 at top of the screen instead of the bottom? Right now I am doing something like this which shows a snackbar at the bottom of the screen. Snackbar.make(findViewById(android.R.id.content), "Hello this is a snackbar!!!", Snackbar.LENGTH_LONG).setAction("Undo", mOnClickListener) .setActionTextColor(Color.RED) .show(); Adarsh Yadav It is possible to make

Add margins to Snackbar view

狂风中的少年 提交于 2019-11-27 07:45:53
问题 I'm updating my current app to use snackbars, in the Google spec they show various ways of using them http://www.google.com/design/spec/components/snackbars-toasts.html#snackbars-toasts-specs Example A: Example B: Here's my code atm: Snackbar snackbar = Snackbar.make(mParentLayout, displayMessage, Snackbar.LENGTH_LONG); snackbar.setAction(actionMessage, mClickListener); snackbar.show(); I get the result in Example B, How can i add margins? 回答1: In addition to Saeid's answer, you can get the

Android - Snackbar vs Toast - usage and difference

拈花ヽ惹草 提交于 2019-11-27 05:33:20
问题 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 snackbar doc. Snackbars provide lightweight feedback about an operation in a small popup at the base of the screen on mobile and at the lower left on desktop. They are above all over elements on screen, including the FAB. and toasts. Android also