Reveal effect with custom color

Dominik Suszczewicz
UIAndroid
Published in
2 min readDec 29, 2016

Reveal effect is a simple animation introduced in Android Lolipop. Reveal animation provide users visual continuity when you show or hide a group of UI elements.

Is is simple to create Animator

But there is no place for color in argument — how can we set it then?

Idea

The basic idea is to create temporary View with custom color above container and set reveal effect to it.

Use ViewGroupOverlay to draw above containerView.

ViewGroupOverlay is extra layer that sits on top of a ViewGroup which is drawn after all other content in that View. The size of revealView need to be added manually, because it doesn’t sit in regular layout hierarchy.

Then create Animator for temporary View

To calculate radius for reveal effect use Pythagorean theorem

To make this smooth dissappear effect create another animator on alpha property

Wire both animators with correct order

And finaly we can start this masterpiece

Github & Apk

--

--