bannerbar icon indicating copy to clipboard operation
bannerbar copied to clipboard

Slightly larger Snackbar with multiple actions

Travis CI Maven Central OpenJDK

Bannerbar

Light example Dark example

Bannerbar is essentially a material banner displayed like a snackbar. Imagine it as a dialog that doesn't interrupt the whole Activity.

  • Following material guidelines, it can only have up to 2 actions.
  • Title are always present, icon and subtitle are optional.
  • Shares Snackbar styles and abilities: respects floating action button position, dismissible by a swipe, etc.

Caveats

Since it uses a lot of Snackbar resources and API, there are a few:

  • Only safe to use with the same version of material components.
  • Deceptive package name.

Download

This library follows AndroidX's revisions.

repositories {
    mavenCentral()
    google()
}
dependencies {
    implementation "com.google.android.material:material:$version"
    implementation "com.hendraanggrian.material:bannerbar:$version"
    implementation "com.hendraanggrian.material:bannerbar-ktx:{version}" // optional Kotlin extensions
}

Snapshots of the development version are available in Sonatype's snapshots repository.

Usage

Bannerbar usage is similar to Snackbar.

Bannerbar.make(parent, "No internet connection", Bannerbar.LENGTH_INDEFINITE)
    .setIcon(R.drawable.my_image)
    .addAction("Retry") { }
    .show()

With bannerbar-ktx, this process can be quicker.

parent.bannerbar("No internet connection") {
    setIcon(R.drawable.my_image)
    addAction("Retry") { }
}