Hidden APIs of Android, Part 1—<blink> tag

Andranik Azizbekian
2 min readNov 25, 2017

In this series I’m going to talk about APIs of Android, that most of developers, despite being quite experienced with Android SDK, do not know about their existence.

Image, that for some weird reason you have got a specification to implement such a feature:

Topeka app

Basically, you have to blink your view hierarchy indeterminately.

How are you going to achieve this?

Sure there are plenty of ways to implement it. But turns out there exists a specific API for this use-case. It’s the <blink> tag that will do the magic for you. All you have to do is to wrap your view hierarchy with that tag:

<blink android:layout_width="match_parent"
android:layout_height="match_parent">

<FrameLayout>
...
</FrameLayout>
</blink>

That’s it, this will make your view hierarchy to “party like it’s 1995!”. Wonder where is the quote taken from? Perfect time to dive into sources.

As you know, it’s the LayoutInflater that will create View out of the xml resource id that is provided as an input parameter to LayoutInflater. As soon as LayoutInflater will start to parse the tags of the xml, it will eventually end up calling createViewFromTag() :

View createViewFromTag(View parent, String name, ...) {
...
if (name.equals(TAG_1995)) {
// Let's party like it's 1995!
return new BlinkLayout(context, attrs);
}
...
}

Here you can see how the magic happens. If name is equal to blink , then a BlinkLayout would be created, which is a private static class declared in LayoutInflater . Here’s the full implementation of BlinkLayout, which is quite easy to understand.

Note: there is no way to control blink in/out timing, it’s 500ms by default.

Clap if you liked the post. Subscribe to get updated with the next episodes of these series.

Happy droiding! 🤖

--

--

Andranik Azizbekian

Android enthusiast, Google Certified Android developer, Stackoverflower