Android : one or two flashy tips

Ever wanted to use the same FloatingActionButton for several purposes without poping/replacing it ?
If your need is to change the color of your button to fade it smoothly, you can think of a color fading animation.
This can be useful if you want to recycle a « play » button as a « stop » button.

You can save your breathe implementing this animation by using this code : https://gist.github.com/anonymous/0e985307c0e1e11c589b8932b2913fd9#file-fromcolortocolor-java

What if you have a material design app, with a tab layout (several tabs) and you want to make it less linear, by scrolling the fabs in an original way ?

You can make a page listener on the ViewPager and implement some animation cases according to the currently active tab : https://gist.github.com/anonymous/0e985307c0e1e11c589b8932b2913fd9#file-onpagelistener-java
In this example, we have three tabs. In the first tab, the fab pops over the screen. In the second one, the fab scrolls slower than the screen, and in the third one, it scrolls up from the bottom right corner of the screen.

Feel free to use these snippets. If you want to see this animations in action, just download my app at https://play.google.com/store/apps/details?id=org.toilelibre.libe.athg2sms.

Thanks for reading me and happy 2017.

Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *

*