Android Snackbar from the Top (similar to Crouton)

Related tags

Snackbar TSnackBar
Overview

Top Snackbar

Sadly, I don't have time to maintain this. If you'd like to be a maintainer, drop me a message in an issue

Android Arsenal Download

Show a Snackbar from the top. A big thanks to https://github.com/ejohansson, https://github.com/antoninovitale, https://github.com/hansonchris and everyone that took the time to make pull requests.

alt text

Icons support:

alt text

Installation (app's build.gradle):

compile 'com.androidadvance:topsnackbar:$version'

How to use it (a tutorial starting from simple usage to complex one):

Example 1: Simple usage:
TSnackbar.make(findViewById(android.R.id.content),"Hello from TSnackBar.",TSnackbar.LENGTH_LONG).show();
Example 2: Custom colors:
TSnackbar snackbar = TSnackbar.make(findViewById(android.R.id.content), "A Snackbar is a lightweight material design method for providing feedback to a user, while optionally providing an action to the user.", TSnackbar.LENGTH_LONG);
snackbar.setActionTextColor(Color.WHITE);
View snackbarView = snackbar.getView();
snackbarView.setBackgroundColor(Color.parseColor("#CC00CC"));
TextView textView = (TextView) snackbarView.findViewById(com.androidadvance.topsnackbar.R.id.snackbar_text);
textView.setTextColor(Color.YELLOW);
snackbar.show();
Example 3: Give 'em everything you got:
//vectordrawable
TSnackbar snackbar = TSnackbar
        .make(relative_layout_main, "Snacking with VectorDrawable", TSnackbar.LENGTH_LONG);
        snackbar.setActionTextColor(Color.WHITE);
        snackbar.setIconLeft(R.drawable.ic_android_green_24dp, 24);
        View snackbarView = snackbar.getView();
        snackbarView.setBackgroundColor(Color.parseColor("#CC00CC"));
        TextView textView = (TextView) snackbarView.findViewById(com.androidadvance.topsnackbar.R.id.snackbar_text);
        textView.setTextColor(Color.YELLOW);
        snackbar.show();

  //left and right icon
 TSnackbar snackbar = TSnackbar
         .make(relative_layout_main, "Snacking Left & Right", TSnackbar.LENGTH_LONG);
         snackbar.setActionTextColor(Color.WHITE);
         snackbar.setIconLeft(R.mipmap.ic_core, 24); //Size in dp - 24 is great!
         snackbar.setIconRight(R.drawable.ic_android_green_24dp, 48); //Resize to bigger dp
         snackbar.setIconPadding(8);
         snackbar.setMaxWidth(3000); //if you want fullsize on tablets
         View snackbarView = snackbar.getView();
         snackbarView.setBackgroundColor(Color.parseColor("#CC00CC"));
         TextView textView = (TextView) snackbarView.findViewById(com.androidadvance.topsnackbar.R.id.snackbar_text);
         textView.setTextColor(Color.YELLOW);
         snackbar.show();

Troubleshooting

  1. Make sure you have the latest shit. At this moment: compileSdkVersion 99+, targetSdkVersion 99+, buildToolsVersion "99.0.1", compile 'com.android.support:appcompat-v7:99.1.0', compile 'com.android.support:design:99.1.0' etc.
  2. Notice that, if you use findViewById(android.R.id.content) your tsnackbar might appear over your notifications bar (the one with the clock, battery). To fix it, replace it with your view, coordinator layout etc.
  3. If your TSnackbar appears with padding on the sides, make sure the parent view doesn't have padding.
  4. Note: remember to use CoordinatorLayout if you get some strange behaviour!

Updates, Questions, and Requests

Ping me here :)

Want to contribute ?

You are a hero.

TODO://

  • Persistent mode.
  • Waiting for your suggestions

Changes List

1.1.1: added .setMaxWidth() method to make (ex: you want them to appear larger(fullwith) on tablets)

You like this library ? Check:

Stargazers over time

Stargazers over time

License

Copyright 2015 AndroidAdvance.com

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

   http://www.apache.org/licenses/LICENSE-2.0

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.
Comments
  • The TSnackBar is showing over the ToolBar

    The TSnackBar is showing over the ToolBar

    I tried the TSnackBar library with all the requirements you mentioned, but the TSnackBar is showing over the ToolBar.

    Is there any way I can do about it ?

    opened by geekyfox90 16
  • Cancel/remove Snackbar when user touch on any parts of screen

    Cancel/remove Snackbar when user touch on any parts of screen

    When tooltip is visible and user click on any other part of the screen say user click on button and tooltip is visible and then user click on different button is any way we can cancel or remove Snackbar instead of waiting for Snackbar duration time to get overWhen Snackbar is visible and user click on any other part of the screen say user click on button and Snackbar is visible and then user click on different button is any way we can cancel or remove Snackbar instead of waiting for tooltip duration time to get over

    opened by GauravP123 10
  • Sometimes it does not show

    Sometimes it does not show

    I do not know why, it does not show, I setted it behind the Toolbbar. I found that when i start an activity when it is still showing on the current activity, i won't show any more. For example, I show it in LoginActivity as a test, but when I start MainActivity when it is still showing, the TSnackbar won't showing anymore. It seems that you have to wait till the current showing TSnackbar is hidden. I am an Android beginner.

    opened by bineanfrank 9
  • Display Snackbar below android.support.v7.widget.Toolbar

    Display Snackbar below android.support.v7.widget.Toolbar

    Is there a way to display the TSnackbar under the android Toolbar? Your sample code contains a coordinator layout, but I use a different activity main layout:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
    
        <android.support.v7.widget.Toolbar
            android:id="@+id/tool_bar"
            style="@style/AppTheme.CustomToolbar"/>
    
        <FrameLayout
            android:id="@+id/fragment_placeholder"
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>
    
    </LinearLayout>
    

    fragment_placeholder is obviously a layout where I add fragments.

    The problem is that it doesn't matter what view I provide to TSnackbar.make, the snackbar always appears over my Toolbar, but below the notification panel (where the battery and other stuff is displayed, as you describe in the README). I want to display the snackbar below the Toolbar so it overlays a bit of "fragment_placeholder", but nothing from "tool_bar". I hope this is possible.

    opened by martinvano 6
  • Added TSnackbar.setMaxWidth() method to allow overriding value

    Added TSnackbar.setMaxWidth() method to allow overriding value

    The max width value is already set through the layout but is not exposed for clients to change it. In most cases, changing the max width is not necessary, especially because it currently matches Google's Material guidelines. But there may be cases where a designer would prefer to treat this as simply an animated view that shows at the top of the screen instead of a snackbar.

    opened by hansonchris 4
  • Include custom icon on

    Include custom icon on "dismiss" button

    So I was wondering if it's possible to implement a way to add a custom icon at the same place that "UNDO" is supposed to be. I was able to add an icon on the left and it was great, but I need to also add a "close" custom icon on the right side.

    Thank you for this great lib, and I would appreciate if you could help me out on that.

    opened by yannbf 3
  • fix issues: the current implementation was calling the callback to di…

    fix issues: the current implementation was calling the callback to di…

    …smiss the view probably with a different timing that caused the callback not to be cleaned correctly (I copied and pasted the current snackbar code, changing the animation accordingly).

    opened by antoninovitale 3
  • Add ability to define an action that doesn't dismiss snackbar on click

    Add ability to define an action that doesn't dismiss snackbar on click

    Add the ability to define an action that won't dismiss the snackbar on the action click

    I'm using TSnackbar as a network issue alert with length indeterminate, opening settings with action button. I'd like to not dismiss on click as the network issues haven't necessarily been resolved. Quick example: snackbar.setAction("Open Wifi Settings", false, v -> NetworkUtil.openWifiSettings(this));

    Note: I'm not breaking existing setAction's, e.g:

    snackbar.setAction("Open Wifi Settings", v -> NetworkUtil.openWifiSettings(this)); will still dismiss on click by default.

    opened by ahaverty 2
  • Cannot be used with custom toolbar

    Cannot be used with custom toolbar

    If i use a custom toolbar....and even if I set it as setSupportActionBar the snackbar will appear over the toolbar rather than below the custom toolbar

    opened by rajas47 2
  • Landscape Softkey moves view up, snackbar start is moved up

    Landscape Softkey moves view up, snackbar start is moved up

    In landscape mode, when the softkey opens, and I call a snackbar, I pass in my activity.getWindow().getDecorView().getRootView() and the view is moved up thus the snack bar starts at the top of the view bottom, and only 10% of the snackbar view is visible at the end of the animation.

    opened by ersin-ertan 2
  • android.view.InflateException: Binary XML file line #17: Error inflating class com.androidadvance.topsnackbar.TSnackbar$SnackbarLayout

    android.view.InflateException: Binary XML file line #17: Error inflating class com.androidadvance.topsnackbar.TSnackbar$SnackbarLayout

    android.view.InflateException: Binary XML file line #17: Error inflating class com.androidadvance.topsnackbar.TSnackbar$SnackbarLayout whats wrong?help me,thank you

    opened by azhen111 2
  • Bintray deprecated

    Bintray deprecated

    Since Bintray is retired, I would suggest switching to maven central. If you prefer a quick fix, I would suggest at-least creating a git tag 1.1.1 so people can download it using jitpack as:

    allprojects {
        repositories {
            ...
            maven { url 'https://jitpack.io' }
        }
    }
    
    dependencies {
            implementation 'com.github.AndreiD:TSnackBar:1.1.1'
    }
    
    opened by mohsin 0
  • dependency issue

    dependency issue

    when i add a dependency , i just make new project nothing elase

     implementation 'com.android.support:appcompat-v7:28.0.0'
        implementation 'com.androidadvance:topsnackbar:1.1.1'
    

    it through me error as i post below.

    Error: Program type already present: android.support.design.widget.CoordinatorLayout$1

    opened by vishalpatel1327 1
  • Move other views by layout_dodgeInsetEdges

    Move other views by layout_dodgeInsetEdges

    First of all: Thanks for the library. I really like it!

    I want to move some views with the appearance of the TSnackbar using layout_dodgeInsetEdges. Currently, I can't get it to work. Does this support this at all? Do I need to use it in a specific way?

    Currently i use a android.support.design.widget.CoordinatorLayout as container and apply app:layout_dodgeInsetEdges="top"to one of it's existing childs. But it doesn't get moved when the TSnackbar appears.

    Any helpful advice is very much appreciated.

    opened by tobsinger 1
  • Create AAR ot JAR file.

    Create AAR ot JAR file.

    Hi,

    Can you provide the AAR file or JAR file so that I can implement cause we got our own gradle tool and need to migration with the AAR or JAR file.

    I already try to get the .aar generate by rebuild in android studio but it's not working.

    opened by o1xhack 1
Owner
Dan Ξ
You can contact me via: https://keybase.io/andyx https://gitcoin.co/andreid
Dan Ξ
The usual Snackbar with more 🍫 and colours :tada:

ChocoBar The usual Snackbar with more ?? and colours ?? . Inspired by Light. GIF AndroidPub Post You can read the AndroidPub post about this library,

Pradyuman Dixit 124 Dec 20, 2022
Snacky is a small library to help you adding a Snackbar to your android project.

Snacky Snacky is a small library to help you adding a Snackbar to your layout with ease. It was created because of my own needs and is inspired by Toa

Mate 492 Dec 7, 2022
The usual Snackbar with more 🍫 and colours :tada:

ChocoBar The usual Snackbar with more ?? and colours ?? . Inspired by Light. GIF AndroidPub Post You can read the AndroidPub post about this library,

Pradyuman Dixit 124 Dec 20, 2022
a Custom Snackbar Library for Jetpack Compose 🚀🎨

?? Snackie is a custom snackbar library for jetpack compose built without using the built in snackbar component ?? Implementation repositories { ma

MathRoda 10 Dec 24, 2022
Android library used to create an awesome Android UI based on a draggable element similar to the last YouTube graphic component.

Draggable Panel DEPRECATED. This project is not maintained anymore. Draggable Panel is an Android library created to build a draggable user interface

Pedro Vicente Gómez Sánchez 3k Jan 5, 2023
Android library used to create an awesome Android UI based on a draggable element similar to the last YouTube New graphic component.

Please switch to DragView, for the best support, thank you DraggablePanel Download allprojects { repositories { ... maven { url 'https://jitp

Hoàng Anh Tuấn 103 Oct 12, 2022
A component for flip animation on Android, which is similar to the effect in Flipboard iPhone/Android

android-flip Aphid FlipView is a UI component to accomplish the flipping animation like Flipboard does. A pre-built demo APK file for Android OS 2.2+

Bo 2.8k Dec 21, 2022
Android library used to create an awesome Android UI based on a draggable element similar to the last YouTube graphic component.

Draggable Panel DEPRECATED. This project is not maintained anymore. Draggable Panel is an Android library created to build a draggable user interface

Pedro Vicente Gómez Sánchez 3k Dec 6, 2022
FixedHeaderTableLayout is a powerful Android library for displaying complex data structures and rendering tabular data composed of rows, columns and cells with scrolling and zooming features. FixedHeaderTableLayout is similar in construction and use as to Android's TableLayout

FixedHeaderTableLayout is a powerful Android library for displaying complex data structures and rendering tabular data composed of rows, columns and cells with scrolling and zooming features. FixedHeaderTableLayout is similar in construction and use as to Android's TableLayout

null 33 Dec 8, 2022
Android library implementing a fading effect for the action bar, similar to the one found in the Play Music app

FadingActionBar FadingActionBar is a library which implements the cool fading action bar effect that can be seen in the new Play Music app. This libra

Manuel Peinado Gallego 2.9k Nov 21, 2022
Android Library for a DrawerLayout similar to the one in Google Apps

GoogleNavigationDrawerMenu This project aims to let you use a ListView menu similar to the one in the new Google Apps (Keep, Play Music...) without ha

Jorge Martin Espinosa 267 Nov 25, 2022
An implement of ProgressHUD for Android, similar to MBProgressHUD, SVProgressHUD for iOS.

KProgressHUD A progress HUD implementation for Android. Inspired by MBProgressHUD for iOS. Compatibility Android 2.3 and later Adding KProgressHUD to

Kaopiz Software Co., Ltd. 1.6k Dec 27, 2022
An Android Toast replacement, similar to the one seen in the GMail app.

MessageBar An Android Toast replacement, similar to the one seen in the GMail app. Multiple messages can be posted in succession, and each message wil

Simon Vig Therkildsen 555 Nov 25, 2022
Android library implementing a poppy view on scroll, similar to the one found in the Google Plus app

PoppyView PoppyView is a library which implements view on the bottom which come and go relative to the user scroll. It can be seen in the Google plus

Flavien Laurent 409 Nov 23, 2022
A beautiful Android custom View that works similar to a range or seekbar. With animations.

ValueBar A beautiful Android custom View that works similar to a range or seekbar. Selection by gesture. With animations. Supporting API level 11+. De

Philipp Jahoda 147 Nov 20, 2022
A library for Android provides blurred drop shadows to ImageView similar to iOS image backdrop shadows

A library for Android provides blurred drop shadows to ImageView similar to iOS image backdrop shadows.Provides fast canvas draw as no renderscript needed .The similar shadow blurred effects can also be seen in iOS Music App.

Vivek Verma 163 Dec 31, 2022
A Reeder copycat, in order to give Android an RSS reader similar to Reeder

A Reeder copycat, in order to give Android an RSS reader similar to Reeder, combines the interaction logic of Reeder with the design style of Material Design 3 (You).

Ashinch 1.5k Dec 31, 2022
Simple star rating system bars, a view similar to the ones seen on Google Playstore. ⭐🌟✨

RatingReviews RatingReviews (Rating and Reviews) is a widget and layout that adds a "Rating & Reviews" bar to your app, similar to the ones seen on Go

Taufiq Rahman 166 Nov 26, 2022
Kotlin HTTP requests library. Similar to Python requests.

khttp khttp is a simple library for HTTP requests in Kotlin. It functions similarly to Python's requests module. import khttp.get fun main(args: Arra

Anna Clemens 466 Dec 20, 2022
A tiling scrollview to display large picture (similar to iOS "CATiledLayer")

Project is not maintained right now. Please see the note at the end of this file. Introduction This Android widget aims to provide a scalable way to d

Sebastian Roth 245 Nov 25, 2022