TSnackBar


Source link: https://github.com/AndreiD/TSnackBar

Top Snackbar

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.

Icons support:

Installation (app's build.gradle):

compile 'com.androidadvance:topsnackbar:1.1.1' 

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:

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. 

Resources

Deal with Android M permissions in runtime in a simple way with reactive programming. This library was developed in Kotlin but can interoperate with Java.

This library is an easy to use series of commands to interact with a hashmap across multiple fragments attached to any running activity. This also allows users to pass information between fragments, without a transaction or bundle.

Endless background scrolling for Android.

Utility for creating ContentProviders without boilerplate and with heavy customization options.

ThirtyInch - a MVP library for Android.

The perfect distance to the Android Framework is approximately thirty inches, the average length of the human arm, shoulder to fingertips.

The EllipsizeTextView extends TextView and supports to omit redundant characters in situation with multiple lines.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes