android-snackbar

How do I change an Android Snackbar's initial alignment from bottom to top?

倖福魔咒の 提交于 2019-11-30 11:35:25
The recent android library came out just a few days ago, but I would like to have the SnackBar appear on top of the screen, preferably within a RelativeLayout as it's parent view. How does one change the SnackBar 's initial alignment which I presume to be layout_alignParentBottom to layout_alignParentTop ? apollow 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 =

What are the new features of Android Design Support Library and how to use its Snackbar?

南笙酒味 提交于 2019-11-30 10:20:27
问题 Android M Preview for developers was released yesterday. As usual, many amazing new features are introduced. I noticed that Snackbar is one of them. I have read the document about Snackbar , from which I learnt that Snackbar is in the library of Android Design Support Library, whose absolute path is android.support.design.widget.Snackbar. And the document says that: Snackbars provide lightweight feedback about an operation. They show a brief message at the bottom of the screen on mobile and

How to change background color of the snackbar?

一世执手 提交于 2019-11-30 06:18:57
问题 I am showing snackbar in DialogFragment Within the Positive click of alertDialog. Here is my code snippet. Snackbar snackbar = Snackbar.make(view, "Please enter customer name", Snackbar.LENGTH_LONG) .setAction("Action", null); View sbView = snackbar.getView(); sbView.setBackgroundColor(Color.BLACK); snackbar.show(); I am passing view of the dialogfragment to the snackbar. I want the background color black? How can I do this? I am returning alertDialog in the DialogFragment. And the theme I am

How do I change an Android Snackbar's initial alignment from bottom to top?

六眼飞鱼酱① 提交于 2019-11-29 17:11:30
问题 The recent android library came out just a few days ago, but I would like to have the SnackBar appear on top of the screen, preferably within a RelativeLayout as it's parent view. How does one change the SnackBar 's initial alignment which I presume to be layout_alignParentBottom to layout_alignParentTop ? 回答1: 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();

ArrayIndexOutOfBoundsException while dismissing Snackbar/ViewDragHelper

▼魔方 西西 提交于 2019-11-29 06:36:02
After implementing the new Snackbar in a few of my applications, I am receiving the following error: java.lang.ArrayIndexOutOfBoundsException: length=1; index=1 at android.support.v4.widget.ViewDragHelper.shouldInterceptTouchEvent(SourceFile:1014) at android.support.design.widget.SwipeDismissBehavior.onInterceptTouchEvent(SourceFile:188) at android.support.design.widget.Snackbar$Behavior.onInterceptTouchEvent(SourceFile:659) at android.support.design.widget.Snackbar$Behavior.onInterceptTouchEvent(SourceFile:641) at android.support.design.widget.CoordinatorLayout.performIntercept(SourceFile:343

How to fix the Snackbar height and position?

拈花ヽ惹草 提交于 2019-11-29 04:36:23
On Android Support Library 24.1.1 , the Snackbar was working fine: Then starting on Android Support Library 24.2.0 onwards, the Snackbar started to behave like this: On the library revision history , there is the following statement: Behavior changes: Snackbar now draws behind the navigation bar if the status bar is translucent. But the thing is that my app is full screen and it doesn't have the navigation bar or the status bar. How can I fix it? Alexandr Larin Look this answer https://stackoverflow.com/a/42180120/2550743 and just replace params.setMargins(params.leftMargin, params.topMargin,

Display SnackBar in Flutter

吃可爱长大的小学妹 提交于 2019-11-28 22:50:27
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, ), home: new MyHomePage(), ); } } class MyHomePage extends StatefulWidget { MyHomePage({Key key}) : super

Snackbar is not working within fragment class

不打扰是莪最后的温柔 提交于 2019-11-28 21:02:12
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 initUI(View view) { btn= (Button) view.findViewById(R.id.btnpress); btn.setOnClickListener(new View

Android - Snackbar vs Toast - usage and difference

僤鯓⒐⒋嵵緔 提交于 2019-11-28 18:30:28
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 provides a capsule-shaped toast, primarily used for system messaging. Toasts are similar to snackbars but

How to change background color of the snackbar?

↘锁芯ラ 提交于 2019-11-28 17:08:11
I am showing snackbar in DialogFragment Within the Positive click of alertDialog. Here is my code snippet. Snackbar snackbar = Snackbar.make(view, "Please enter customer name", Snackbar.LENGTH_LONG) .setAction("Action", null); View sbView = snackbar.getView(); sbView.setBackgroundColor(Color.BLACK); snackbar.show(); I am passing view of the dialogfragment to the snackbar. I want the background color black? How can I do this? I am returning alertDialog in the DialogFragment. And the theme I am setting to the dialog as follow's <style name="MyAlertDialogStyle" parent="Theme.AppCompat.Light