Every Android Developer knows about the Snackbar, which is an important component introduced in Material Design. It is similar to Toast used for android Development. But the Snackbar had provides action callback to perform action like Click-listeners in Button. In this article, we are going to learn How to Customize the Snackbar.
For Full Reference, Download whole source code from the github link and post your comments. If you like this post, provide one star in Github or Like my Page. For any suggestions, feel free to post comments.
Download From Github
Summary
We are going learn,
- Implementation of Default Snackbar
- Implementation of Snackbar with action callback
- Snackbar with custom gravity for message text
- Snackbar with custom color
- Snackbar with custom text color for message and action.
- Snackbar with custom typeface for message text and action text.
- Implementation of Top Snackbar
Implementation of Default Snackbar
Below is the syntax of a simple Snackbar. The make function accepts three parameters. View, display message and duration of the message to be displayed.
Snackbar.make(v, "Normal Snackbar", Snackbar.LENGTH_LONG).show();
Implementation of Snackbar with action callback
Below is the syntax to display snackbar with action callback
Snackbar.make(v, "Snackbar with Action", Snackbar.LENGTH_LONG)
.setAction("UNDO", new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Action!", Snackbar.LENGTH_SHORT).show();
}
}).setActionTextColor(Color.RED).show();
Snackbar with custom gravity for message text
Below is the syntax to display snackbar with custom gravity
Snackbar mSnackBar = Snackbar.make(v, "Snackbar with Custom Gravity", Snackbar.LENGTH_LONG);
TextView mainTextView = (TextView) (mSnackBar.getView()).findViewById(android.support.design.R.id.snackbar_text);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
mainTextView.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
else
mainTextView.setGravity(Gravity.CENTER_HORIZONTAL);
mainTextView.setGravity(Gravity.CENTER_HORIZONTAL);
mSnackBar.show();
Snackbar with custom color
Below is the syntax to display snackbar with custom color
Snackbar mSnackBar = Snackbar.make(v, "Custom Snackbar", Snackbar.LENGTH_LONG);
// To Change Snackbar Color
mSnackBar.getView().setBackgroundColor(Color.WHITE);
mSnackBar.show();
Snackbar with custom text color for message and action
Below is the syntax to display snackbar with custom text color
Snackbar mSnackBar = Snackbar.make(v, "Custom Snackbar", Snackbar.LENGTH_LONG);
TextView mainTextView = (TextView) (mSnackBar.getView()).findViewById(android.support.design.R.id.snackbar_text);
TextView actionTextView = (TextView) (mSnackBar.getView()).findViewById(android.support.design.R.id.snackbar_action);
// To Change Text Color for Message and Action
mainTextView.setTextColor(Color.BLACK);
actionTextView.setTextColor(Color.BLACK);
mSnackBar.show();
Snackbar with custom typeface for message text and action text
Below is the syntax to display snackbar with custom Typeface
Snackbar mSnackBar = Snackbar.make(v, "Custom Snackbar", Snackbar.LENGTH_LONG);
TextView mainTextView = (TextView) (mSnackBar.getView()).findViewById(android.support.design.R.id.snackbar_text);
TextView actionTextView = (TextView) (mSnackBar.getView()).findViewById(android.support.design.R.id.snackbar_action);
// To Apply Custom Fonts for Message and Action
Typeface font = Typeface.createFromAsset(getAssets(), "Lato-Regular.ttf");
mainTextView.setTypeface(font);
actionTextView.setTypeface(font);
mSnackBar.show();
Implementation of Top Snackbar
Below is the syntax to display snackbar from screen Top
Snackbar mSnackBar = Snackbar.make(v, "TOP SNACKBAR", Snackbar.LENGTH_LONG);
View view = mSnackBar.getView();
FrameLayout.LayoutParams params =(FrameLayout.LayoutParams)view.getLayoutParams();
params.gravity = Gravity.TOP;
view.setLayoutParams(params);
view.setBackgroundColor(Color.RED);
TextView mainTextView = (TextView) (view).findViewById(android.support.design.R.id.snackbar_text);
mainTextView.setTextColor(Color.WHITE);
mSnackBar.show();
For more, Details Please download whole project source from Github.
55 comments
commentsThis is a wonderful article, Given so much info in it, These type of articles keeps the users interest in the website, and keep on sharing more ... good luck.
ReplyAndroid training in chennai with placement | Android Training in chennai |Android Training in Velachery
This information is impressive; I am inspired with your post writing style & how continuously you describe this topic. After reading your post, thanks for taking the time to discuss this, I feel happy about it and I love learning more about this topic.Android Training in chennai with placement | Android Training in velachery
ReplyWhatever we gathered information from the blogs, we should implement that in practically then only we can understand that exact thing clearly, but it’s no need to do it, because you have explained the concepts very well. It was crystal clear, keep sharing..
ReplyJava Training in Chennai
Java Training in Coimbatore
Java Training in Bangalore
Nice article I was really impressed by seeing this blog, it was very interesting and it is very useful for me.
ReplyMachine Learning course in Chennai
Machine Learning Certification
Machine Learning Chennai
Data Science Training in Chennai
RPA Training in Chennai
AWS Training in Chennai
Machine Learning Training in T Nagar
Machine Learning Training in OMR
Machine Learning Training in Adyar
Machine Learning Training in Porur
Valuable blog....waiting for next update...
ReplySpring Training in Chennai
Spring and Hibernate Training
Spring framework Certification
spring training in vadapalani
spring training in Guindy
Hibernate Training in Chennai
javascript training in chennai
QTP Training in Chennai
Mobile Testing Training in Chennai
SAS Training in Chennai
Wonderful Blog!!! Thanks for sharing this post with us... and it is more helpful for us.
ReplyIOS Training in Chennai
ios training institute in chennai
Best ios Training institutes in Chennai
ios developer course in chennai
IOS training in OMR
IOS Training in Annanagar
Big data training in chennai
JAVA Training in Chennai
Selenium Training in Chennai
JAVA Training in Chennai
Nice blog....waiting for next update....
ReplyStruts Training in Chennai
Struts Training center in Chennai
Struts course in Chennai
Struts Training in Velachery
Struts Training in Tambaram
Wordpress Training in Chennai
SAS Training in Chennai
Spring Training in Chennai
Photoshop Classes in Chennai
DOT NET Training in Chennai
Great info. Thanks for spending your valuable time to share this post.
ReplySpoken English Classes in Chennai
Spoken English Class in Chennai
Spoken English in Chennai
IELTS Training in Chennai
IELTS Chennai
Best English Speaking Classes in Mumbai
Spoken English Classes in Mumbai
IELTS Mumbai
IELTS Coaching in Anna Nagar
Spoken English Class in T Nagar
Nice content and blog...Thanks for sharing, Waiting for next...
ReplyWordpress Training in Chennai
Wordpress Training Chennai
Wordpress Training Institutes in Chennai
wordpress training in Thiruvanmiyur
Wordpress Training in Velachery
Struts Training in Chennai
clinical sas training in chennai
Spring Training in Chennai
Photoshop Classes in Chennai
LoadRunner Training in Chennai
This stays as one of the best and attractive post I have read yet. Great sharing this post.
ReplyIELTS Training in Tambaram
IELTS Training in Velachery
IELTS Training in T Nagar
Spoken English Classes in Chennai
Best Spoken English Classes in Chennai
IELTS Coaching Centre in Chennai
IELTS Coaching in Chennai
English Speaking Classes in Mumbai
English Speaking Course in Mumbai
IELTS Coaching in Mumbai
I want to thank for sharing this blog, really great and informative. Share more stuff like this.
ReplyEthical Hacking course in Chennai
Ethical Hacking Training in Chennai
Hacking course
ccna course in Chennai
Salesforce Training in Chennai
Angular 7 Training in Chennai
Web Designing course in Chennai
Ethical Hacking course in Thiruvanmiyur
Ethical Hacking course in Porur
Ethical Hacking course in Adyar
awesome article,the content has very informative ideas, waiting for the next update...
Replyclinical sas training in chennai
clinical sas training fees
clinical sas training in vadapalani
clinical sas training in Guindy
clinical sas training in Thiruvanmiyur
SAS Training in Chennai
Spring Training in Chennai
LoadRunner Training in Chennai
QTP Training in Chennai
javascript training in chennai
Nice Blog!! Thanks For Sharing! Keep update more information..
ReplyTally Course in Chennai
Tally Classes in Chennai
Tally training coimbatore
Tally course in madurai
Tally Training in Chennai
Tally Institute in Chennai
Tally Training Institute in Chennai
ielts coaching centre in coimbatore
Thanks for sharing informative article with us...
ReplyQTP Training in Chennai
Qtp classes in chennai
qtp training institutes in chennai
qtp training in Thiruvanmiyur
QTP Training in OMR
LoadRunner Training in Chennai
Html5 Training in Chennai
clinical sas training in chennai
Spring Training in Chennai
Photoshop Classes in Chennai
I appreciate you for this blog. More informative, thanks for sharing with us.
ReplyDOT NET Training in Chennai
DOT NET Training in Bangalore
.Net training in chennai
.net coaching centre in chennai
dot net course in bangalore
DOT NET Course in Chennai
web designing course in madurai
php training in coimbatore
Good blog!!! It is more impressive... thanks for sharing with us...
ReplySelenium Training in Chennai
Best selenium Training Institute in Chennai
selenium testing course in chennai
Selenium Course in Chennai
Selenium training in Thiruvanmiyur
Selenium Training in Velachery
Python Training in Chennai
Software testing training in chennai
Python Training in Chennai
JAVA Training in Chennai
Wonderful article with great piece of information. Thanks for sharing this with us. I'll take reference from your blog. Do share more such informative articles.
ReplyAutomation Anywhere Training in Chennai
Automation Training in Chennai
Automation Training Institute in Chennai
R Training in Chennai
Data Science Training in Chennai
RPA Training in Chennai
Automation Anywhere Training in Adyar
Automation Anywhere Training in Tambaram
Automation Anywhere Training in Anna Nagar
iso registration in delhi
Replyiso 22000 certification cost
ISO 9001 Certification in Noida
website designing services
SEO Service Consultant
iso certification in noida
Replyiso certification in delhi
ce certification in delhi
iso 14001 certification in delhi
iso 22000 certification in delhi
iso consultants in noida
we have provide the best fridge repair service.
Replyfridge repair in faridabad
Videocon Fridge Repair in Faridabad
Whirlpool Fridge Repair in Faridabad
Hitachi Fridge Repair In Faridabad
Washing Machine Repair in Noida
godrej washing machine repair in noida
whirlpool Washing Machine Repair in Noida
IFB washing Machine Repair in Noida
LG Washing Machine Repair in Noida
we have provide the best ppc service.
Replyppc company in gurgaon
website designing company in Gurgaon
PPC company in Noida
seo company in gurgaon
PPC company in Mumbai
PPC company in Chandigarh
Digital Marketing Company
Rice Bags Manufacturers
ReplyPouch Manufacturers
wall putty bag manufacturers
fertilizer bag manufacturers
seed bag manufacturers
gusseted bag manufacturers
bopp laminated bags manufacturer
Lyrics with music
Mobile app development company in mumbai
ReplyNice blog was really feeling good to read it. Thanks for this information.
ReplySpoken English Classes in Chennai
English Speaking Course in Chennai
french classes
pearson vue test center in chennai
IoT Training in Chennai
Xamarin Training in Chennai
Node JS Training in Chennai
content writing training in chennai
Spoken English Classes in OMR
Spoken English Classes in Porur
I am glad that I saw this post. It is informative blog for us and we need this type of blog thanks for share this blog, Keep posting such instructional blogs and I am looking forward for your future posts.
ReplyCyber Security Projects for Final Year
JavaScript Training in Chennai
Project Centers in Chennai
JavaScript Training in Chennai
Great blog thanks for sharing The world around is changing at turbo speed. With digital marketing companies booming up at every corner, it can be hard to decide which is the best place for you to begin your online marketing journey. If you are based in Chennai, the answer is plain simple - Adhuntt Media has the best team that cover all your branding needs - SEO, Graphic Design, Logo Design, Social Media Marketing, Google Ads, Competitor Analysis and much more.
Replydigital marketing agency in chennai
Nice blog thanks for sharing Set up your very own unique and classy vertical garden in Chennai. Karuna Nursery Gardens offers you with all the tools and services for building the best vertical garden in your neighbourhood.
Replyplant nursery in chennai
Excellent blog thanks for sharing It’s time you upgraded your Salon to meet global standards. Do that with the best wholesale cosmetic market in Chennai - The Pixies Beauty Shop.
ReplyCosmetics Shop in Chennai
This was really an interesting topic and I kinda agree with what you have mentioned here!
ReplyAlcatel Mobile Price in Bangladesh
Great blog thanks for sharing Take care of all your search engine optimization SEO, graphic design, logo creation, social media marketing and digital branding need at one stop - Adhuntt Media. Customer satisfaction and service is our priority - We tread that fine line between projecting your visions into tangible reality! Why wait when you can begin your digital marketing journey with us right now at Adhuntt Media.
Replydigital marketing company in chennai
Nice blog thanks for sharing Tidy up your ambience by decorating them with amazing landscape plants in Chennai. Karuna Nursery Gardens is your portal to all the green that the world has to offer. Revolutionize your indoors, garden, terrace or office right now with us.
Replyplant nursery in chennai
Excellent blog thanks for sharing Buy the best beauty parlour products wholesale in Chennai at Pixies Beauty Shop. Thousands of global top-tier brands to choose from and friendly faces all over, we would love to make your Salon journey, one the world recognizes.
Replybeauty Shop in Chennai
Thanks for your blog!!.
ReplyJAVA Development Services
HR Pay Roll Software
SAP Software Services
Hotel Billing Software
Web Design Company
Hospital Management Software
I am glad that I saw this post. It is informative blog for us and we need this type of blog thanks for share this blog, Keep posting such instructional blogs and I am looking forward for your future posts.
ReplyCyber Security Projects for Final Year
JavaScript Training in Chennai
Project Centers in Chennai
JavaScript Training in Chennai
please checkout all samsung smartphones.Samsung Mobile Price in Bangladesh 2020
Replynice blog
ReplyGreat Information.
#makeupCourse #NutritionCourse #HairCourse #SpaCourse #CosmetologyCourse #NailCourse #AestheticsCourse
Makeup Course
Shweta gaur is one of the famous makeup artist in all over India. We are providing the best makeup artist courses and more other courses in over branches in Delhi.
ReplyBridal Makeup Makeup Artist in Delhi Makeup Artist Best Makeup Artist in Delhi Best Makeup Artist in East Delhi Top Makeup Artist in Delhi Top Makeup Artist in India Bridal Makeup
Best Bridal Makeup Artist in Delhi Bridal Makeup Artist in Delhi with Price Bridal Makeup Artist in Delhi NCR Top Bridal Makeup Artist in Delhi Bridal Makeup in Delhi Bridal Makeup Charges in Delhi Bridal Makeup Packages Prices Freelance Makeup Artist Bridal Makeup Charges in Delhi Freelance Bridal Makeup Artist in Delhi
nice
ReplyVery useful blog thanks for sharing IndPac India the German technology Packaging and sealing machines in India is the leading manufacturer and exporter of Packing Machines in India.
ReplyI’m amazed, I must say. Rarely do I encounter a blog that’s equally educative and interesting, and without a doubt, you have hit the nail on the head. The issue is something that too few folks are speaking intelligently about. I am very happy tech that I stumbled across this in my hunt for something concerning this.
ReplyPositive site, where did u come up with the information on this posting?I have read a few of the articles on your website now, and I really like your style. Thanks a million and please keep up the effective work.
Replydevops lead jobs
python course in coimbatore
Replypython training in coimbatore
java course in coimbatore
java training in coimbatore
android course in coimbatore
android training in coimbatore
php course in coimbatore
php training in coimbatore
digital marketing course in coimbatore
digital marketing training in coimbatore
software testing course in coimbatore
software testing training in coimbatore
Replypython course in coimbatore
java course in coimbatore
python training in coimbatore
java training in coimbatore
php course in coimbatore
php training in coimbatore
android course in coimbatore
android training in coimbatore
datascience course in coimbatore
datascience training in coimbatore
ethical hacking course in coimbatore
ethical hacking training in coimbatore
artificial intelligence course in coimbatore
artificial intelligence training in coimbatore
digital marketing course in coimbatore
digital marketing training in coimbatore
embedded system course in coimbatore
embedded system training in coimbatore
Nice info..! Really superb and keep doing.....
ReplySpark Training in Chennai
Spark Training Fees in Chennai
Appium Training in Chennai
Tableau Training in Chennai
Pega Training in Chennai
Advanced Excel Training in Chennai
Oracle Training in Chennai
Oracle DBA Training in Chennai
Linux Training in Chennai
Embedded System Course Chennai
Excel Training in Chennai
1movies
Replyputlocker
ReplyFirst of all I would like to thank you for writing this post I love both writing and reading new posts and I was just looking at new posts to see me something new, only then I saw your post and the rest of the post is praiseworthy.
Replysofeeya.com
Really useful information. Thank you so much for sharing.It will help everyone.Keep
ReplyDot Net Training in Chennai | Dot Net Training in anna nagar | Dot Net Training in omr | Dot Net Training in porur | Dot Net Training in tambaram | Dot Net Training in velachery
ReplyExotic cart is a well known prefilled THC oil cartridge, and stoners from the west to east drift use them. ... Our cartscontain premium lab tried THC Oil which these days, is hard to find. Our pre-filled cannabis cartridges are ideal for vaping Maryjane in a hurry.
mario carts
exotic carts
dankwoods for sale
brass knuckles vape
buy carts
mario carts flavors
buy pink rutz
mario carts online
mario cartridges
mario carts for sale
stiiizy pod
space monkey meds
organic smart carts
mario carts thc
smart carts
buy blue dream online
buy mario carts vape
buy runtz
buy white runtz
710 kingpin vapes
moonrock clear carts
kingpen gelato
buy Ak-47
buy skywalker og online
runtz
rove carts
cereal cart
buy weed
dankvapes
space monkey meds
dank vapes
organic smart carts
mario carts thc
smart carts
buy runtz
710 kingpin vapes
buy afghan haze
buy og kush
buy white runtz
I found some useful information in your blog, it was awesome to read, thanks for sharing this great content to my vision, keep sharing..
ReplyCyber Security Training Course in Chennai | Certification | Cyber Security Online Training Course | Ethical Hacking Training Course in Chennai | Certification | Ethical Hacking Online Training Course | CCNA Training Course in Chennai | Certification | CCNA Online Training Course | RPA Robotic Process Automation Training Course in Chennai | Certification | RPA Training Course Chennai | SEO Training in Chennai | Certification | SEO Online Training Course
I seriously love your site.. Very nice colors & theme. Did you make this site yourself? Please reply back as I’m looking to create my very own website and want to know where you got this from or just what the theme is called. real Kbc Head Office Real Number is here. Many thanks!
ReplyI am suggesting 5 easy sites that will help you to create your own Android apps for free in few minutes? Cyberflix
ReplyGreat Article android based projects
ReplyJava Training in Chennai Project Center in Chennai Java Training in Chennai projects for cse The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training Project Centers in Chennai
Excellent blog thanks for sharing the valuable information..it becomes easy to read and easily understand the information.
ReplyUseful article which was very helpful. also interesting and contains good information.
to know about python training course , use the below link.
Python Training in chennai
Python Course in chennai
Please Comment about the Posts and Blog