Posts

Showing posts with the label Android Snackbar

Android - Snackbar Vs Toast - Usage And Difference

Answer : If I don't require user interaction I would use a toast? You can still use Snackbar. It is not mandatory to have an action with Snackbar. What is meant by "system messaging"? Does that apply to displaying information when something important happened between my app and the Android system? I believe this means that Toasts are to be used if there are some messages pertaining to the system. Either android as a whole or some background service you may be running. E.g. Text-To-Speech is not installed. OR No Email client found. What I like is the swipe off screen feature - would that be a reason to start replacing toasts with Snackbar? (this is a bit opinion based question though) That is one reason. But there are several other plus points. For an example: Your toast remains on screen even when the activity is finished. Snackbar doesn't. There is less confusion if the toast does not popup (or keep popping up in case of multiple Toast creation in seq...

Can We Perform 2 Different Actions In Snack Bar At A Time In Android?

Answer : 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. As @Elias N answer's each Snackbar may contain a single action. If you want to set more then action in Snackbar then you need to create your own layout. Please try this i hope this will help you. Create one xml file my_snackbar.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="50dp" android:background="#000000"> <TextView android:layout_width="0dp" android:layout_height="50dp" android:layout_weight=".7" android:gravity="center_ver...