Flashbar is a Material Design 3 compliant notification library for Android that provides beautiful, customizable, and accessible notification bars with support for animations, swipe-to-dismiss, multiple action buttons, and more.
✨ Material Design 3 Compliance - Follows Google's latest Material Design 3 guidelines with expressive design elements
♿ WCAG 2.1 AA Accessibility - Fully accessible with proper contrast ratios, screen reader support, and keyboard navigation
🎨 Expressive Design - Vibrant color palettes, smooth animations, and delightful interactions
👆 Swipe-to-Dismiss - Intuitive gesture support for dismissing notifications
🎯 Multiple Action Buttons - Support for primary, positive, and negative action buttons
📊 Progress Indicators - Left and right positioned progress bars with customizable styles
🌓 Dark Theme Support - Automatic dark theme adaptation with semantic colors
🎭 Custom Animations - Flexible enter/exit animations with icon animation support
🔔 Vibration Feedback - Haptic feedback on show and dismiss events
⌨️ Keyboard Navigation - Full keyboard support for accessibility
📱 Flexible Positioning - Top or bottom positioning with edge-to-edge support
Add the JitPack repository to your project-level build.gradle or settings.gradle:
dependencyResolutionManagement {
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
}
}Then add the dependency to your module-level build.gradle:
dependencies {
implementation 'com.github.Netsnake-TN:material-flashbar:1.0.0'
}Or add to your build.gradle.kts:
dependencies {
implementation("com.github.Netsnake-TN:material-flashbar:1.0.0")
}Requirements:
- Min SDK: 26 (Android 8.0)
- Target SDK: 35 (Android 15)
- Compile SDK: 35
- Material Components: 1.14.0-alpha08 or higher
Note: Replace 1.0.0 with the latest version from JitPack.
new Flashbar.Builder(activity)
.gravity(Flashbar.Gravity.BOTTOM)
.title("Download Complete")
.message("File has been downloaded successfully")
.primaryActionText("Open")
.primaryActionTapListener(bar -> {
// Handle action
bar.dismiss();
})
.build()
.show();// Success notification
FlashbarPresets.success(this, "Success!", "Your changes have been saved")
.show();
// Error notification with action
FlashbarPresets.error(this, "Error", "Failed to save file")
.primaryActionText("Retry", bar -> retryOperation())
.show();
// Loading indicator
FlashbarPresets.loading(this, "Processing your request...")
.show();The Flashbar library uses the Builder Pattern for fluent API design. All configuration is done through the Flashbar.Builder class, which provides comprehensive customization options.
The main entry point for creating and displaying flashbars.
| Constant | Value | Description |
|---|---|---|
DURATION_SHORT |
1000L | Short duration (1 second) |
DURATION_LONG |
2500L | Long duration (2.5 seconds) |
DURATION_INDEFINITE |
-1L | Indefinite duration (no auto-dismiss) |
Displays the flashbar on the screen with configured animations and settings.
flashbar.show();Note: If the flashbar is already showing, this method does nothing.
Dismisses the flashbar with the configured exit animation.
flashbar.dismiss();Note: If the flashbar is not showing, this method does nothing.
Changes the position of the close button after the flashbar has been created.
flashbar.setCloseButtonPosition(Flashbar.CloseButtonPosition.BOTTOM_CENTER);Parameters:
position- The desired close button position (CENTER_RIGHT, BOTTOM_CENTER, BOTTOM_LEFT)
Sets the tint color for the close button icon.
flashbar.setCloseButtonIconTint(Color.WHITE);Parameters:
color- The tint color to apply
Checks if the flashbar is currently showing (including during show animation).
boolean showing = flashbar.isShowing();Returns: true if showing, false otherwise
Checks if the flashbar has completed showing (animation finished).
boolean shown = flashbar.isShown();Returns: true if shown, false otherwise
Provides fluent API for configuring flashbars.
Creates a new Flashbar Builder.
Flashbar.Builder builder = new Flashbar.Builder(activity);Parameters:
activity- The activity to display the flashbar in
Sets the vertical position of the flashbar.
.gravity(Flashbar.Gravity.BOTTOM)Options:
Gravity.TOP- Position at the top of the screenGravity.BOTTOM- Position at the bottom of the screen (default)
Sets the background color.
.backgroundColor(Color.parseColor("#6750A4"))Sets the background color from a color resource.
.backgroundColorRes(R.color.primaryContainer)Sets a custom background drawable.
.backgroundDrawable(ContextCompat.getDrawable(this, R.drawable.custom_bg))Sets a custom background drawable from a resource.
.backgroundDrawable(R.drawable.custom_bg)Applies a shape appearance overlay style.
.shapeAppearanceOverlay(R.style.ShapeAppearanceOverlay_Expressive)Applies a custom shape appearance model.
ShapeAppearanceModel model = new ShapeAppearanceModel.Builder()
.setAllCorners(CornerFamily.ROUNDED, 24f)
.build();
.shapeAppearanceModel(model)Sets a uniform corner radius for all corners.
.cornerRadius(24f)Sets individual corner radii for each corner.
.cornerRadii(8f, 32f, 16f, 24f)Applies a Material 3 shape style.
.material3ShapeStyle(Flashbar.Material3ShapeStyle.LARGE)Options:
NONE- No corners (sharp edges)EXTRA_SMALL- Extra small corner sizeSMALL- Small corner sizeMEDIUM- Medium corner size (default)LARGE- Large corner sizeEXTRA_LARGE- Extra large corner sizeFULL- Fully rounded corners (pill shape)
Sets the title text.
.title("Notification Title")Sets the title text from a string resource.
.title(R.string.notification_title)Sets a spanned title text (for rich text formatting).
.title(Html.fromHtml("<b>Bold</b> Title"))Sets the title text color.
.titleColor(Color.WHITE)Sets the title text color from a color resource.
.titleColorRes(R.color.onPrimaryContainer)Sets the title text size in pixels.
.titleSizeInPx(24f)Sets the title text size in scaled pixels.
.titleSizeInSp(18f)Sets the title text typeface.
.titleTypeface(Typeface.create("sans-serif-medium", Typeface.NORMAL))Applies a text appearance style to the title.
.titleAppearance(R.style.TextAppearance_Material3_TitleMedium)Sets the title text position.
.titlePosition(Flashbar.TextPosition.CENTER)Options:
DEFAULT- Left aligned (default)CENTER- Center aligned
Sets the message text.
.message("This is the notification message")Sets the message text from a string resource.
.message(R.string.notification_message)Sets a spanned message text (for rich text formatting).
.message(Html.fromHtml("Message with <i>italic</i> text"))Sets the message text color.
.messageColor(Color.WHITE)Sets the message text color from a color resource.
.messageColorRes(R.color.onPrimaryContainer)Sets the message text size in pixels.
.messageSizeInPx(16f)Sets the message text size in scaled pixels.
.messageSizeInSp(14f)Sets the message text typeface.
.messageTypeface(Typeface.create("sans-serif", Typeface.NORMAL))Applies a text appearance style to the message.
.messageAppearance(R.style.TextAppearance_Material3_BodyMedium)Sets the message text position.
.messagePosition(Flashbar.TextPosition.CENTER)Options:
DEFAULT- Left aligned (default)CENTER- Center aligned
Shows the icon with default scale (1.0f) and center crop scale type.
.showIcon()Shows the icon with custom scale.
.showIcon(1.5f)Shows the icon with custom scale and scale type.
.showIcon(1.5f, ImageView.ScaleType.CENTER_INSIDE)Parameters:
scale- Icon scale multiplier (must be > 0)scaleType- ImageView scale type (CENTER_CROP, CENTER_INSIDE, etc.)
Sets the icon drawable.
.icon(ContextCompat.getDrawable(this, R.drawable.ic_notification))Sets the icon from a drawable resource.
.icon(R.drawable.ic_notification)Sets the icon from a bitmap.
.icon(bitmap)Applies a color filter to the icon (default mode: SRC_IN).
.iconColorFilter(Color.WHITE)Applies a color filter to the icon with specified mode.
.iconColorFilter(Color.WHITE, PorterDuff.Mode.SRC_IN)Applies a color filter from a color resource.
.iconColorFilterRes(R.color.icon_tint)Sets a custom icon animation.
.iconAnimation(FlashAnim.with(this).animateIcon().pulse().duration(1000))Sets the primary action button text.
.primaryActionText("OK")Sets the primary action button text from a string resource.
.primaryActionText(R.string.action_ok)Sets a spanned action button text.
.primaryActionText(Html.fromHtml("<b>OK</b>"))Sets the primary action button text color.
.primaryActionTextColor(Color.WHITE)Sets the primary action button text color from a color resource.
.primaryActionTextColorRes(R.color.onPrimary)Sets the primary action button background color.
.primaryActionBackgroundColor(Color.parseColor("#6750A4"))Sets the primary action button background color from a color resource.
.primaryActionBackgroundColorRes(R.color.primary)Sets the primary action button text size in pixels.
.primaryActionTextSizeInPx(16f)Sets the primary action button text size in scaled pixels.
.primaryActionTextSizeInSp(14f)Sets the primary action button text typeface.
.primaryActionTextTypeface(Typeface.DEFAULT_BOLD)Applies a text appearance style to the primary action button.
.primaryActionTextAppearance(R.style.TextAppearance_Material3_LabelLarge)Sets the primary action button position.
.primaryButtonPosition(Flashbar.PrimaryButtonPosition.BOTTOM_RIGHT)Options:
CENTER_RIGHT- Center right (default)BOTTOM_CENTER- Bottom centerBOTTOM_RIGHT- Bottom right
Sets the primary action button style.
.primaryButtonStyle(Flashbar.ButtonStyle.TEXT_ONLY)Options:
DEFAULT- Default filled buttonTEXT_ONLY- Text only buttonICON_ONLY- Icon only button
Sets the primary action button icon.
.primaryActionIcon(R.drawable.ic_check)Sets the primary action button tap listener.
.primaryActionTapListener(bar -> {
// Handle action
bar.dismiss();
})Convenience method to set both text and listener.
.primaryAction("OK", bar -> bar.dismiss())Convenience method to set text from resource and listener.
.primaryAction(R.string.action_ok, bar -> bar.dismiss())Positive Action Button Methods
Same methods as primary action button, but for the positive (accept) action:
positiveActionText(String text)positiveActionText(@StringRes int actionTextId)positiveActionText(Spanned actionText)positiveActionTextColor(@ColorInt int color)positiveActionTextColorRes(@ColorRes int colorId)positiveActionBackgroundColor(@ColorInt int color)positiveActionBackgroundColorRes(@ColorRes int colorId)positiveActionTextSizeInPx(float size)positiveActionTextSizeInSp(float size)positiveActionTextTypeface(Typeface typeface)positiveActionTextAppearance(@StyleRes int appearance)positiveButtonStyle(ButtonStyle style)positiveActionIcon(@DrawableRes int iconRes)positiveActionTapListener(OnActionTapListener listener)positiveAction(String text, OnActionTapListener listener)positiveAction(@StringRes int textResId, OnActionTapListener listener)
Negative Action Button Methods
Same methods as primary action button, but for the negative (decline) action:
negativeActionText(String text)negativeActionText(@StringRes int actionTextId)negativeActionText(Spanned actionText)negativeActionTextColor(@ColorInt int color)negativeActionTextColorRes(@ColorRes int colorId)negativeActionBackgroundColor(@ColorInt int color)negativeActionBackgroundColorRes(@ColorRes int colorId)negativeActionTextSizeInPx(float size)negativeActionTextSizeInSp(float size)negativeActionTextTypeface(Typeface typeface)negativeActionTextAppearance(@StyleRes int appearance)negativeButtonStyle(ButtonStyle style)negativeActionIcon(@DrawableRes int iconRes)negativeActionTapListener(OnActionTapListener listener)negativeAction(String text, OnActionTapListener listener)negativeAction(@StringRes int textResId, OnActionTapListener listener)
Shows the close button (default).
.showCloseButton()Shows or hides the close button.
.showCloseButton(true)Enables the dismiss button (auto-dismiss action button).
.enableDismissButton()Enables or disables the dismiss button.
.enableDismissButton(true)Note: When dismiss button is enabled, close button is automatically disabled.
Sets the close button position.
.closeButtonPosition(Flashbar.CloseButtonPosition.BOTTOM_LEFT)Options:
CENTER_RIGHT- Center right (default)BOTTOM_CENTER- Bottom centerBOTTOM_LEFT- Bottom left
Sets the close button icon tint color.
.setCloseButtonIconTint(Color.WHITE)Sets the close button icon size in density-independent pixels.
.setCloseButtonIconSize(32)Sets the close button icon padding in density-independent pixels.
.setCloseButtonIconPadding(8)Sets the close button style from a style resource.
.setCloseButtonStyle(R.style.Widget_Material3_Button_IconButton)Shows a progress indicator at the specified position.
.showProgress(Flashbar.ProgressPosition.LEFT)Options:
LEFT- Show progress on the left sideRIGHT- Show progress on the right side
Note: Cannot show progress at left if icon is set, or at right if action button is set.
Sets the progress indicator color.
.progressTint(Color.parseColor("#6750A4"))Sets the progress indicator color from a color resource.
.progressTintRes(R.color.primary)Sets the loading indicator style.
.loadingStyle(Flashbar.LoadingStyle.CONTAINED)Options:
NORMAL- Normal loading indicator (default)CONTAINED- Contained loading indicator with background
Sets the loading indicator size.
.loadingSize(Flashbar.LoadingSize.LARGE)Options:
SMALL- Small (16dp)MEDIUM- Medium (20dp, default)LARGE- Large (24dp)
Sets the display duration.
.duration(Flashbar.DURATION_LONG)Parameters:
milliseconds- Duration in milliseconds, orDURATION_INDEFINITEfor no auto-dismiss
Throws: IllegalArgumentException if duration is not DURATION_INDEFINITE and not positive
Shows a semi-transparent overlay behind the flashbar.
.showOverlay()Shows an overlay with custom alpha (0.0 to 1.0).
.showOverlay(0.5f)Parameters:
alpha- Overlay opacity (0.0 = transparent, 1.0 = opaque)
Throws: IllegalArgumentException if alpha is not between 0.0 and 1.0
Sets the overlay color.
.overlayColor(Color.parseColor("#80000000"))Sets the overlay color from a color resource.
.overlayColorRes(R.color.scrim_50)Makes the overlay block clicks (default behavior when overlay is shown).
.overlayBlockable()Blocks or allows interaction with the activity when flashbar is shown.
.blockActivityInteraction(true)Parameters:
block-trueto block activity interaction,falseto allow passthrough (default)
Note: This is independent of overlay and dismiss-on-tap-outside functionality.
Enables dismiss on tap outside (default: disabled).
.dismissOnTapOutside()Enables or disables dismiss on tap outside.
.dismissOnTapOutside(true)Sets a listener for taps outside the flashbar.
.listenOutsideTaps(flashbar -> {
// Handle outside tap
})Sets a listener for taps on the flashbar.
.listenBarTaps(flashbar -> {
// Handle bar tap
})Sets the enter animation.
.enterAnimation(FlashAnim.with(this).animateBar().enter().fromBottom().overshoot().duration(400))Sets the exit animation.
.exitAnimation(FlashAnim.with(this).animateBar().exit().fromBottom().accelerate().duration(300))Enables swipe-to-dismiss gesture.
.enableSwipeToDismiss()Enables or disables swipe-to-dismiss gesture.
.enableSwipeToDismiss(true)Sets when to vibrate.
.vibrateOn(Flashbar.Vibration.SHOW, Flashbar.Vibration.DISMISS)Options:
Vibration.SHOW- Vibrate when flashbar is shownVibration.DISMISS- Vibrate when flashbar is dismissed
Sets a listener for show events.
.barShowListener(new Flashbar.OnBarShowListener() {
@Override
public void onShowing(Flashbar bar) {
// Called when show animation starts
}
@Override
public void onShowProgress(Flashbar bar, float progress) {
// Called during show animation (progress: 0.0 to 1.0)
}
@Override
public void onShown(Flashbar bar) {
// Called when show animation completes
}
})Sets a listener for dismiss events.
.barDismissListener(new Flashbar.OnBarDismissListener() {
@Override
public void onDismissing(Flashbar bar, boolean isSwiped) {
// Called when dismiss animation starts
}
@Override
public void onDismissProgress(Flashbar bar, float progress) {
// Called during dismiss animation (progress: 0.0 to 1.0)
}
@Override
public void onDismissed(Flashbar bar, Flashbar.DismissEvent event) {
// Called when dismiss animation completes
// event can be TIMEOUT, MANUAL, TAP_OUTSIDE, or SWIPE
}
})Builds the Flashbar instance.
Flashbar flashbar = new Flashbar.Builder(activity)
.title("Title")
.message("Message")
.build();Returns: A configured Flashbar instance
Builds and immediately shows the flashbar.
new Flashbar.Builder(activity)
.title("Title")
.message("Message")
.show();Vertical positioning options.
Flashbar.Gravity.TOP // Position at top
Flashbar.Gravity.BOTTOM // Position at bottom (default)Dismiss event types.
Flashbar.DismissEvent.TIMEOUT // Dismissed due to timeout
Flashbar.DismissEvent.MANUAL // Dismissed manually via dismiss()
Flashbar.DismissEvent.TAP_OUTSIDE // Dismissed by tapping outside
Flashbar.DismissEvent.SWIPE // Dismissed by swipingHaptic feedback targets.
Flashbar.Vibration.SHOW // Vibrate when shown
Flashbar.Vibration.DISMISS // Vibrate when dismissedProgress indicator position options.
Flashbar.ProgressPosition.LEFT // Show progress on left
Flashbar.ProgressPosition.RIGHT // Show progress on rightClose button position options.
Flashbar.CloseButtonPosition.CENTER_RIGHT // Center right (default)
Flashbar.CloseButtonPosition.BOTTOM_CENTER // Bottom center
Flashbar.CloseButtonPosition.BOTTOM_LEFT // Bottom leftText position options for title and message.
Flashbar.TextPosition.DEFAULT // Left aligned (default)
Flashbar.TextPosition.CENTER // Center alignedPrimary button position options.
Flashbar.PrimaryButtonPosition.CENTER_RIGHT // Center right (default)
Flashbar.PrimaryButtonPosition.BOTTOM_CENTER // Bottom center
Flashbar.PrimaryButtonPosition.BOTTOM_RIGHT // Bottom rightAction button style options.
Flashbar.ButtonStyle.DEFAULT // Default filled button
Flashbar.ButtonStyle.TEXT_ONLY // Text only button
Flashbar.ButtonStyle.ICON_ONLY // Icon only buttonLoading indicator style options.
Flashbar.LoadingStyle.NORMAL // Normal loading indicator (default)
Flashbar.LoadingStyle.CONTAINED // Contained loading indicator with backgroundLoading indicator size options.
Flashbar.LoadingSize.SMALL // Small (16dp)
Flashbar.LoadingSize.MEDIUM // Medium (20dp, default)
Flashbar.LoadingSize.LARGE // Large (24dp)Material 3 shape style constants.
Flashbar.Material3ShapeStyle.NONE // No corners (sharp edges)
Flashbar.Material3ShapeStyle.EXTRA_SMALL // Extra small corner size
Flashbar.Material3ShapeStyle.SMALL // Small corner size
Flashbar.Material3ShapeStyle.MEDIUM // Medium corner size (default)
Flashbar.Material3ShapeStyle.LARGE // Large corner size
Flashbar.Material3ShapeStyle.EXTRA_LARGE // Extra large corner size
Flashbar.Material3ShapeStyle.FULL // Fully rounded corners (pill shape)Listener for action button taps.
public interface OnActionTapListener {
void onActionTapped(Flashbar bar);
}Usage:
.primaryActionTapListener(bar -> {
// Handle action
bar.dismiss();
})Listener for dismiss events.
public interface OnBarDismissListener {
void onDismissing(Flashbar bar, boolean isSwiped);
void onDismissProgress(Flashbar bar, float progress);
void onDismissed(Flashbar bar, DismissEvent event);
}Usage:
.barDismissListener(new Flashbar.OnBarDismissListener() {
@Override
public void onDismissing(Flashbar bar, boolean isSwiped) {
// Called when dismiss starts
}
@Override
public void onDismissProgress(Flashbar bar, float progress) {
// Called during dismiss (0.0 to 1.0)
}
@Override
public void onDismissed(Flashbar bar, Flashbar.DismissEvent event) {
// Called when dismiss completes
}
})Listener for tap events.
public interface OnTapListener {
void onTap(Flashbar flashbar);
}Usage:
.listenBarTaps(bar -> {
// Handle bar tap
})Listener for show events.
public interface OnBarShowListener {
void onShowing(Flashbar bar);
void onShowProgress(Flashbar bar, float progress);
void onShown(Flashbar bar);
}Usage:
.barShowListener(new Flashbar.OnBarShowListener() {
@Override
public void onShowing(Flashbar bar) {
// Called when show starts
}
@Override
public void onShowProgress(Flashbar bar, float progress) {
// Called during show (0.0 to 1.0)
}
@Override
public void onShown(Flashbar bar) {
// Called when show completes
}
})Preconfigured Flashbar presets for common use cases.
Creates a success notification with green accent.
// With string text
FlashbarPresets.success(activity, "Success!", "Your changes have been saved")
.show();
// With string resources
FlashbarPresets.success(activity, R.string.success_title, R.string.success_message)
.show();
// With action button
FlashbarPresets.success(activity, "Success!", "File uploaded successfully")
.primaryActionText("View", bar -> openFile())
.show();Creates an error notification with red accent.
// With string text
FlashbarPresets.error(activity, "Error", "Failed to save file")
.show();
// With string resources
FlashbarPresets.error(activity, R.string.error_title, R.string.error_message)
.show();
// With action button
FlashbarPresets.error(activity, "Error", "Connection failed")
.primaryActionText("Retry", bar -> retryConnection())
.show();Creates a warning notification with amber accent.
// With string text
FlashbarPresets.warning(activity, "Warning", "Your session will expire soon")
.show();
// With string resources
FlashbarPresets.warning(activity, R.string.warning_title, R.string.warning_message)
.show();
// With action button
FlashbarPresets.warning(activity, "Warning", "Low battery")
.primaryActionText("Save", bar -> saveWork())
.show();Creates an info notification with blue accent.
// With string text
FlashbarPresets.info(activity, "Information", "New features are available")
.show();
// With string resources
FlashbarPresets.info(activity, R.string.info_title, R.string.info_message)
.show();
// With action button
FlashbarPresets.info(activity, "Update Available", "Version 2.0 is ready")
.primaryActionText("Update", bar -> startUpdate())
.show();Creates a neutral notification with gray accent for non-critical messages.
// With string text
FlashbarPresets.neutral(activity, "Notification", "This is a neutral message")
.show();
// With string resources
FlashbarPresets.neutral(activity, R.string.neutral_title, R.string.neutral_message)
.show();Creates a critical notification with strong red accent for destructive actions.
// With string text
FlashbarPresets.critical(activity, "Critical", "Data loss detected")
.show();
// With string resources
FlashbarPresets.critical(activity, R.string.critical_title, R.string.critical_message)
.show();Creates a toast-style minimal notification with auto-dismiss.
// With string text
FlashbarPresets.toast(activity, "Message saved")
.show();
// With string resources
FlashbarPresets.toast(activity, R.string.toast_message)
.show();Creates a minimal notification with centered text and auto-dismiss.
// Short duration
FlashbarPresets.minimal(activity, "Title", "Message", Flashbar.DURATION_SHORT)
.show();
// Long duration
FlashbarPresets.minimal(activity, "Title", "Message", Flashbar.DURATION_LONG)
.show();Creates a generic notification with custom background color.
// With string text
FlashbarPresets.custom(activity, "Title", "Message", Color.parseColor("#6750A4"))
.show();
// With string resources
FlashbarPresets.custom(activity, R.string.title, R.string.message, Color.parseColor("#6750A4"))
.show();Creates a loading notification with progress indicator.
// With string text
FlashbarPresets.loading(activity, "Processing your request...")
.show();
// With string resources
FlashbarPresets.loading(activity, R.string.loading_message)
.show();Creates a notification with Material 3 primary color styling.
// With string text
FlashbarPresets.primary(activity, "Title", "Message")
.show();
// With string resources
FlashbarPresets.primary(activity, R.string.title, R.string.message)
.show();new Flashbar.Builder(this)
.title("Welcome!")
.message("Thanks for using our app")
.gravity(Flashbar.Gravity.BOTTOM)
.show();new Flashbar.Builder(this)
.title("Success!")
.message("Your profile has been updated")
.backgroundColorRes(R.color.successContainer)
.titleColorRes(R.color.onSuccessContainer)
.messageColorRes(R.color.onSuccessContainer)
.icon(R.drawable.ic_check_circle)
.primaryActionText("View Profile", bar -> {
startActivity(new Intent(this, ProfileActivity.class));
bar.dismiss();
})
.show();new Flashbar.Builder(this)
.title("Connection Error")
.message("Failed to connect to server")
.backgroundColorRes(R.color.errorContainer)
.titleColorRes(R.color.onErrorContainer)
.messageColorRes(R.color.onErrorContainer)
.icon(R.drawable.ic_error)
.positiveActionText("Retry", bar -> {
retryConnection();
bar.dismiss();
})
.negativeActionText("Cancel", bar -> bar.dismiss())
.duration(Flashbar.DURATION_INDEFINITE)
.show();Flashbar loadingBar = new Flashbar.Builder(this)
.title("Loading")
.message("Please wait...")
.showProgress(Flashbar.ProgressPosition.LEFT)
.progressTintRes(R.color.primary)
.duration(Flashbar.DURATION_INDEFINITE)
.showCloseButton(false)
.build();
loadingBar.show();
// Later, dismiss when done
loadingBar.dismiss();new Flashbar.Builder(this)
.title("Swipe to Dismiss")
.message("You can swipe this notification away")
.enableSwipeToDismiss()
.barDismissListener(new Flashbar.OnBarDismissListener() {
@Override
public void onDismissing(Flashbar bar, boolean isSwiped) {
if (isSwiped) {
Log.d("Flashbar", "Dismissed by swipe");
}
}
@Override
public void onDismissProgress(Flashbar bar, float progress) {
Log.d("Flashbar", "Swipe progress: " + progress);
}
@Override
public void onDismissed(Flashbar bar, Flashbar.DismissEvent event) {
Log.d("Flashbar", "Dismissed: " + event);
}
})
.show();new Flashbar.Builder(this)
.title("Custom Animations")
.message("This notification has custom animations")
.enterAnimation(FlashAnim.with(this)
.animateBar()
.enter()
.fromBottom()
.overshoot()
.duration(500))
.exitAnimation(FlashAnim.with(this)
.animateBar()
.exit()
.fromBottom()
.accelerate()
.duration(300))
.show();new Flashbar.Builder(this)
.title("Modal Notification")
.message("This blocks interaction with the activity")
.showOverlay()
.overlayColorRes(R.color.scrim_50)
.blockActivityInteraction(true)
.dismissOnTapOutside(true)
.duration(Flashbar.DURATION_INDEFINITE)
.show();new Flashbar.Builder(this)
.title("Custom Shape")
.message("This has fully rounded corners")
.material3ShapeStyle(Flashbar.Material3ShapeStyle.FULL)
.show();new Flashbar.Builder(this)
.title("Animated Icon")
.message("The icon is pulsing")
.icon(R.drawable.ic_notification)
.iconAnimation(FlashAnim.with(this)
.animateIcon()
.pulse()
.duration(1000))
.show();new Flashbar.Builder(this)
.title("Confirm Action")
.message("Are you sure you want to delete this item?")
.positiveActionText("Delete", bar -> {
deleteItem();
bar.dismiss();
})
.negativeActionText("Cancel", bar -> bar.dismiss())
.show();new Flashbar.Builder(this)
.title("Centered Title")
.message("Centered message text")
.titlePosition(Flashbar.TextPosition.CENTER)
.messagePosition(Flashbar.TextPosition.CENTER)
.show();new Flashbar.Builder(this)
.title("With Haptics")
.message("This vibrates on show and dismiss")
.vibrateOn(Flashbar.Vibration.SHOW, Flashbar.Vibration.DISMISS)
.show();new Flashbar.Builder(this)
.title("Custom Close Button")
.message("The close button is customized")
.showCloseButton()
.closeButtonPosition(Flashbar.CloseButtonPosition.BOTTOM_LEFT)
.setCloseButtonIconTint(Color.WHITE)
.setCloseButtonIconSize(32)
.setCloseButtonIconPadding(8)
.show();FlashbarPresets.progressWithPercentage(this, "Downloading", "File download", 45)
.show();new Flashbar.Builder(this)
.title("Keyboard Accessible")
.message("Press ESC or BACK to dismiss")
.show();
// Users can press ESC or BACK key to dismissFlashbar supports Material 3 theming with semantic colors. Define these colors in your theme:
<style name="Theme.App" parent="Theme.Material3.DayNight">
<!-- Flashbar Semantic Colors -->
<item name="colorSuccessContainer">@color/successContainer</item>
<item name="colorOnSuccessContainer">@color/onSuccessContainer</item>
<item name="colorWarningContainer">@color/warningContainer</item>
<item name="colorOnWarningContainer">@color/onWarningContainer</item>
<item name="colorInfoContainer">@color/infoContainer</item>
<item name="colorOnInfoContainer">@color/onInfoContainer</item>
</style>Flashbar is WCAG 2.1 AA compliant and includes:
- Proper color contrast ratios (4.5:1 for normal text, 3:1 for large text)
- Screen reader announcements with descriptive content
- Keyboard navigation support (ESC, BACK keys)
- Touch target sizes meeting Material Design guidelines (minimum 48dp)
- Focus management with visual feedback
If using ProGuard, add these rules:
-keep class com.expressive.flashbar.** { *; }
-keep class com.google.android.material.** { *; }
MIT License
Copyright (c) 2026 Expressive Flashbar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Contributions are welcome! Please follow these steps:
- Fork the project
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
For issues, questions, or suggestions, please open an issue on GitHub.
Made with ❤️ for the Android community