{"id":13507315,"url":"https://github.com/nispok/snackbar","last_synced_at":"2025-12-30T08:51:53.181Z","repository":{"id":19827473,"uuid":"23088566","full_name":"nispok/snackbar","owner":"nispok","description":"[DEPRECATED] Android Library that implements Snackbars from Google's Material Design documentation.","archived":false,"fork":false,"pushed_at":"2015-09-21T02:04:52.000Z","size":3375,"stargazers_count":1527,"open_issues_count":36,"forks_count":237,"subscribers_count":59,"default_branch":"master","last_synced_at":"2024-04-23T11:40:33.123Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nispok.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-08-18T22:23:00.000Z","updated_at":"2024-01-26T09:53:20.000Z","dependencies_parsed_at":"2022-08-25T23:20:49.078Z","dependency_job_id":null,"html_url":"https://github.com/nispok/snackbar","commit_stats":null,"previous_names":["wmora/snackbar"],"tags_count":58,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nispok%2Fsnackbar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nispok%2Fsnackbar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nispok%2Fsnackbar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nispok%2Fsnackbar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nispok","download_url":"https://codeload.github.com/nispok/snackbar/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222535177,"owners_count":16999233,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T02:00:30.988Z","updated_at":"2025-12-16T22:23:33.226Z","avatar_url":"https://github.com/nispok.png","language":"Java","readme":"# DEPRECATED\nThis lib is deprecated in favor of Google's [Design Support Library](http://developer.android.com/tools/support-library/features.html#design) which includes a [Snackbar](http://developer.android.com/reference/android/support/design/widget/Snackbar.html) and is no longer being developed.\n\nThanks for all your support!\n\n# Snackbar\n[![Build Status](https://travis-ci.org/nispok/snackbar.svg?branch=master)](https://travis-ci.org/nispok/snackbar) [![Maven Central](https://img.shields.io/maven-central/v/com.nispok/snackbar.svg)](https://oss.sonatype.org/content/repositories/releases/com/nispok/snackbar/) [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Snackbar-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/1160) [![Android Weekly](https://img.shields.io/badge/Android%20Weekly-129-blue.svg?style=flat)](http://androidweekly.net/issues/issue-129)\n\nLibrary that implements \u003ca href=\"http://www.google.com/design/spec/components/snackbars-and-toasts.html\"\u003eSnackbars\u003c/a\u003e from Google's \u003ca href=\"http://www.google.com/design/spec/material-design/introduction.html\"\u003eMaterial Design documentation\u003c/a\u003e.\nWorks on API levels \u003e= 8\n\n\u003ca href=\"https://play.google.com/store/apps/details?id=com.nispok.samples.snackbar\"\u003e\n  \u003cimg alt=\"Get it on Google Play\"\n       src=\"https://developer.android.com/images/brand/en_generic_rgb_wo_60.png\" /\u003e\n\u003c/a\u003e\n\n\u003cimg src=\"./art/home.png\" alt=\"Example App\" style=\"width: 200px; height: 355px\" /\u003e\n\u003cimg src=\"./art/home-1line.png\" alt=\"Example App\" style=\"width: 200px; height: 355px\" /\u003e\n\u003cimg src=\"./art/home-2line.png\" alt=\"Example App\" style=\"width: 200px; height: 355px\" /\u003e\n\u003cimg src=\"./art/home-colored.png\" alt=\"Example App\" style=\"width: 200px; height: 355px\" /\u003e\n\u003cimg src=\"./art/list-1line.png\" alt=\"Example App\" style=\"width: 200px; height: 355px\" /\u003e\n\n## Installation\nYou can import the library from source as a module or grab via Gradle:\n \n ```groovy\n compile 'com.nispok:snackbar:2.11.+'\n ```\n## Usage\n\nUsing the `Snackbar` class is easy, this is how you would display it on an `Activity`:\n\n```java\nSnackbar.with(getApplicationContext()) // context\n    .text(\"Single-line snackbar\") // text to display\n    .show(this); // activity where it is displayed\n```\nHowever, I recommend you use the `SnackbarManager` to handle the Snackbars queue:\n\n```java\n// Dismisses the Snackbar being shown, if any, and displays the new one\nSnackbarManager.show(\n    Snackbar.with(myActivity)\n    .text(\"Single-line snackbar\"));\n```\nIf you are using `getApplicationContext()` as the `Context` to create the `Snackbar` then you must\nspecify the target `Activity` when calling the `SnackbarManager`:\n\n```java\n// Dismisses the Snackbar being shown, if any, and displays the new one\nSnackbarManager.show(\n    Snackbar.with(getApplicationContext())\n    .text(\"Single-line snackbar\"), myActivity);\n```\nYou can place the `Snackbar` at the bottom of a particular hierarchy of views. The sample app makes\nuse of this; check out [SnackbarImmersiveModeSampleActivity](./sample/src/main/java/com/nispok/samples/snackbar/SnackbarImmersiveModeSampleActivity.java):\n```java\nSnackbarManager.show(Snackbar snackbar, ViewGroup parent) { }\nSnackbarManager.show(Snackbar snackbar, ViewGroup parent, boolean usePhoneLayout) { }\n```\nIf you want an action button to be displayed, just assign a label and an `ActionClickListener`:\n\n```java\nSnackbarManager.show(\n    Snackbar.with(getApplicationContext()) // context\n        .text(\"Item deleted\") // text to display\n        .actionLabel(\"Undo\") // action button label\n        .actionListener(new ActionClickListener() {\n            @Override\n            public void onActionClicked(Snackbar snackbar) {\n                Log.d(TAG, \"Undoing something\");\n            }\n        }) // action button's ActionClickListener\n     , this); // activity where it is displayed\n```\nIf you need to know when the `Snackbar` is shown or dismissed, assign a `EventListener` to it.\nThis is useful if you need to move other objects while the `Snackbar` is displayed. For instance,\nyou can move a Floating Action Button up while the `Snackbar` is on screen. Note that if you only\nneed to override a subset of the interface methods you can extend from `EventListenerAdapter`:\n\n```java\nSnackbarManager.show(\n    Snackbar.with(getApplicationContext()) // context\n        .text(\"This will do something when dismissed\") // text to display\n        .eventListener(new EventListener() {\n            @Override\n            public void onShow(Snackbar snackbar) {\n                myFloatingActionButton.moveUp(snackbar.getHeight());\n            }\n            @Override\n            public void onShowByReplace(Snackbar snackbar) {\n                Log.i(TAG, String.format(\"Snackbar will show by replace. Width: %d Height: %d Offset: %d\",\n                                        snackbar.getWidth(), snackbar.getHeight(),\n                                        snackbar.getOffset()));\n            }\n            @Override\n            public void onShown(Snackbar snackbar) {\n                Log.i(TAG, String.format(\"Snackbar shown. Width: %d Height: %d Offset: %d\",\n                        snackbar.getWidth(), snackbar.getHeight(),\n                        snackbar.getOffset()));\n            }\n            @Override\n            public void onDismiss(Snackbar snackbar) {\n                myFloatingActionButton.moveDown(snackbar.getHeight());\n            }\n            @Override\n            public void onDismissByReplace(Snackbar snackbar) {\n                Log.i(TAG, String.format(\n                                \"Snackbar will dismiss by replace. Width: %d Height: %d Offset: %d\",\n                                snackbar.getWidth(), snackbar.getHeight(),\n                                snackbar.getOffset()));\n            }\n            @Override\n            public void onDismissed(Snackbar snackbar) {\n                Log.i(TAG, String.format(\"Snackbar dismissed. Width: %d Height: %d Offset: %d\",\n                                    snackbar.getWidth(), snackbar.getHeight(),\n                                    snackbar.getOffset()));\n            }\n        }) // Snackbar's EventListener\n    , this); // activity where it is displayed\n```\nThere are two `Snackbar` types: single-line (default) and multi-line (2 lines max. Note this only applies for phones; tablets are always single-line). You can also set\nthe duration of the `Snackbar` similar to a\n\u003ca href=\"http://developer.android.com/reference/android/widget/Toast.html\"\u003e`Toast`\u003c/a\u003e.\n\nThe lengths of a Snackbar duration are:\n* `LENGTH_SHORT`: 2s\n* `LENGTH_LONG`: 3.5s (default)\n* `LENGTH_INDEFINTE`: Indefinite; ideal for persistent errors\n\nYou could also set a custom duration.\n\nAnimation disabling is also possible.\n\n```java\nSnackbarManager.show(\n    Snackbar.with(getApplicationContext()) // context\n        .type(Snackbar.SnackbarType.MULTI_LINE) // Set is as a multi-line snackbar\n        .text(\"This is a multi-line snackbar. Keep in mind that snackbars are \" +\n            \"meant for VERY short messages\") // text to be displayed\n        .duration(Snackbar.SnackbarDuration.LENGTH_SHORT) // make it shorter\n        .animation(false) // don't animate it\n    , this); // where it is displayed\n```\nYou can also change the `Snackbar`'s colors and fonts.\n\n```java\nSnackbarManager.show(\n    Snackbar.with(getApplicationContext()) // context\n        .text(\"Different colors this time\") // text to be displayed\n        .textColor(Color.GREEN) // change the text color\n        .textTypeface(myTypeface) // change the text font\n        .color(Color.BLUE) // change the background color\n        .actionLabel(\"Action\") // action button label\n        .actionColor(Color.RED) // action button label color\n        .actionLabelTypeface(myTypeface) // change the action button font\n        .actionListener(new ActionClickListener() {\n            @Override\n            public void onActionClicked(Snackbar snackbar) {\n                Log.d(TAG, \"Doing something\");\n            }\n         }) // action button's ActionClickListener\n    , this); // activity where it is displayed\n```\nFinally, you can attach the `Snackbar` to a AbsListView (ListView, GridView) or a RecyclerView.\n\n```java\nSnackbarManager.show(\n    Snackbar.with(getApplicationContext()) // context\n        .type(Snackbar.SnackbarType.MULTI_LINE) // Set is as a multi-line snackbar\n        .text(R.string.message) // text to be displayed\n        .duration(Snackbar.SnackbarDuration.LENGTH_LONG)\n        .animation(false) // don't animate it\n        .attachToAbsListView(listView) // Attach to ListView - attachToRecyclerView() is for RecyclerViews\n        , this); // where it is displayed\n```\nIt uses [Roman Nurik's SwipeToDismiss sample code](https://github.com/romannurik/android-swipetodismiss)\nto implement the swipe-to-dismiss functionality. This is enabled by default. You can disable this if\nyou don't want this functionality:\n\n**NOTE:** This has no effect on apps running on APIs \u003c 11; swiping will always be disabled in those cases\n\n```java\nSnackbarManager.show(\n    Snackbar.with(SnackbarSampleActivity.this) // context\n        .text(\"Can't swipe this\") // text to be displayed\n        .swipeToDismiss(false) // disable swipe-to-dismiss functionality\n    , this); // activity where it is displayed\n```\n\n# Examples\nThere's a sample app included in the project. [SnackbarSampleActivity](./sample/src/main/java/com/nispok/samples/snackbar/SnackbarSampleActivity.java) is where you want to start.\n\n# Apps Using Snackbar\n* [Imagine for Instagram](https://play.google.com/store/apps/details?id=com.imagine.free)\n* [Kuantize](https://play.google.com/store/apps/details?id=eu.pedrofonseca.compras)\n\n# Contributing\nIf you would like to add features or report any bugs, open a [PR](https://github.com/nispok/snackbar/pulls) or refer to the [issues](https://github.com/nispok/snackbar/issues) section.\n\n# Contributors\nThanks to all [contributors](https://github.com/nispok/snackbar/graphs/contributors)!\n\n# License\n[MIT](./LICENSE)\n\n# ChangeLog\nGo to the [releases](https://github.com/nispok/snackbar/releases) section for a brief description of each release.\n","funding_links":[],"categories":["Index `(light-weight pages)`","Libs","\u003ca name=\"SnackBar\"\u003eSnackBar\u003c/a\u003e","Android"],"sub_categories":["\u003cA NAME=\"Widget\"\u003e\u003c/A\u003eWidget","Personal Blog"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnispok%2Fsnackbar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnispok%2Fsnackbar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnispok%2Fsnackbar/lists"}