Muddz Muddz - 2 months ago 20
Android Question

How to define a Toast style in style.xml?

Can a

Toast
be styled in
style.xml
like we do for Activity themes?

I want to style the following:


  • Text color

  • Text Size

  • Text font

  • Background color/opacity

  • Background Radius of corners and sizes



I can't find anything that relates to Toast on the web or in the style.xml

I have solved it by making an StyleableToast class which you can easily use to style your Toasts in almost any way! See answer here: http://stackoverflow.com/a/39591755/5366495

Answer

Since there was not an easy and a non messy way (layouts,inflating etc) to style a Toast, I decicided then to make a complete Styleable Toast class with a lot of styling possibilities!

I will keep improve the Styleable Toast class and make it feature rich and release it in the jCenter() so it can be added as an dependency

Here is it. Just a single class you put in your project: https://github.com/Muuddz/StyleableToast

Examples of toasts made with StyleableToast:

enter image description here

All feedback and feature requests is welcome!