Snackbar with API 21

With the new Design Support Library you can use the official SnackBar Widget.

Just add this dependency to your app -> build.gradle:

implementation 'com.android.support:design:28.0.0'

And use something like:

Snackbar.make(view, "Snackbar", Snackbar.LENGTH_LONG).show();

enter image description here

Full Example, In Kotlin

        val fab = findViewById(R.id.btn_signin) as Button
        fab.setOnClickListener(View.OnClickListener { view ->
            Snackbar.make(view, "FloatingActionButton is clicked", Snackbar.LENGTH_INDEFINITE)
                    .setAction("Action", null).show()
        })

You should try to use Android Studio, because the ADT plugin for Eclipse is no longer in active development.

In Android Studio, you just need to add a line compile 'com.nispok:snackbar:2.6.1' in your build.gradle dependencies, such that

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.2'
    compile 'com.nispok:snackbar:2.6.1'
}

That's it.


If you are facing "not resolved to a type" issue in Eclipse for Snackbar, this worked for me.

Right click on Project->BuildPath->Configure Buildpath Click on Libraries Tab and then click on Add external Libraries.

Select {path of adt}/sdk/extras/android/support/design/libs Select android-support-design.jar, Click Open to add this library.

Click Ok.

Final Window