This library provides a lightweight and customizable Snackbar component for Android applications, based on the Snackbar implementation in AnkiDroid. It offers a user-friendly interface for displaying brief messages at the bottom of the screen, serving as informative or actionable prompts for users.
- Easy integration with minimal configuration
- Customizable appearance and behavior to match your app's design
- Support for various durations including short and long display times
- Callback functionalities for handling user interactions with the Snackbar
- Accessibility support for users with diverse needs
To integrate the Snackbar library into your Android project, simply add the library as a dependency in your project's build.gradle file. Ensure that you have the necessary Android SDK version compatible with the library.
Add it in your root build.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
- For
.kts
maven { url = uri("https://jitpack.io") }
Tag is the latest release version
For build.gradle
dependencies {
implementation 'com.github.criticalAY:ASnack:Tag'
}
For build.gradle.kts
implementation("com.github.criticalAY:ASnack:Tag")
- Initialize the Snackbar component within your activity or fragment.
- You can create snackbars by calling
showSnackbar
on either an activity or a view. AsCoordinatorLayout
is responsible for proper placement and animation of snackbars, if calling on an activity, the activity MUST have aCoordinatorLayout
with idroot_layout
; if calling on a view, the view MUST be either aCoordinatorLayout
, or a (possibly indirect) child ofCoordinatorLayout
. Any additional configuration can be done in the configuration block, e.g.
showSnackbar(text) {
addCallback(callback)
}
- The activity that is the receiver must have a
CoordinatorLayout
with id 'root_layout' snackbarBuilder
is Optional.
This library is a derivative work based on the Snackbar component extracted from AnkiDroid, an open-source Android flashcard application. We acknowledge and appreciate the work done by AnkiDroid team in developing the original Snackbar implementation.