Need help with CookieBar2?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

487 Stars 55 Forks Apache License 2.0 51 Commits 0 Opened issues


CookieBar2 is an Android library for displaying messages, notifications and alerts at the top or bottom of the screen. A great alternative for toast messages. Excellent replacement for snackbar notifications. Android messages never looked better!

Services available


Need anything else?

Contributors list

# 111,434
38 commits
# 213,520
8 commits
# 394,780
1 commit

Android Arsenal Codacy Badge AndroidWeekly335

CookieBar 2

CookieBar is a lightweight library for showing a brief message at the top or bottom of the screen.

implementation 'org.aviran.cookiebar2:cookiebar2:1.1.4'


Main differences from the original Cookiebar library are:

  • Swipe to dismiss has been added.
  • Programmatic dismiss functionality added.
  • Only one Cookie can be displayed at a time (New top cookie will dismiss the current top one if exists).
  • Message view captures clicks, blocks downward propagation.
  • Slightly different build interface.
  • Icon animator support.
  • Custom layout can be applied to a cookie.
  • Colors presets added.
  • Root view can be overridden and customized.
  • Removed supportRtl / allowBackup from library scope (Set at app level when necessary).

Create a simple cookie

Using Kotlin           // Provide activity, using [email protected] / getActivity() or otherwise
         .setTitle("TITLE")         // String resources are also supported
         .setMessage("MESSAGE")     // i.e. R.string.message
         .show()                    // Cookies are displayed at the top by default

Using Java
         .setCookiePosition(CookieBar.BOTTOM)  // Cookie will be displayed at the bottom
         .show();                              // of the screen

Customize colors, icon, icon animation, call to action button, display duration
         .setAction(R.string.action_text) { 
              // Action code - Do something
         .setDuration(5000) // 5 seconds

Customize in/out animation
         .setAnimationIn(android.R.anim.slide_in_left, android.R.anim.slide_in_left)
         .setAnimationOut(android.R.anim.slide_out_right, android.R.anim.slide_out_right)

Programmatically dismiss cookies currently being displayed


Create a cookie with a custom layout - Create a dialog!
         .setCustomViewInitializer { view ->
             val btnNew = view.findViewById(
             val btnOpen = view.findViewById(
             val btnSave = view.findViewById(
             val btnListener = View.OnClickListener { view ->
                 val button = view as Button
         .setAction("Close") { CookieBar.dismiss(activity) }
/* setCustomView -  Set the layout resource for your custom cookie view.
   setCustomViewInitializer - Called after layout inflation, for subview setup. */ .setCustomView(R.layout.custom_cookie) .setCustomViewInitializer(new CookieBar.CustomViewInitializer() { @Override public void initView(View view) {

                       Button btnNew = view.findViewById(;
                       Button btnOpen = view.findViewById(;
                       Button btnSave = view.findViewById(;

                       View.OnClickListener btnListener = new View.OnClickListener() {

                                public void onClick(View view) {
                                         Button button = (Button) view;

     .setAction("Close", new OnActionClickListener() {
              public void onClick() {
     .setEnableAutoDismiss(false) // Cookie will stay on display until manually dismissed
     .setSwipeToDismiss(false)    // Deny dismiss by swiping off the view

Change default cookie style by setting theme attributes

Dynamically set cookie properties

  • Cookie position (Top/Bottom)
  • Display duration
  • Title text color
  • Body text color
  • Action text color
  • Background color
  • Icon resource
  • Icon animation
  • In/Out animations for the entire view
  • View layout


Forked from the early code base of CookieBar, by Eric Liu.


Copyright 2018, Aviran Abady.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.