May 27, 2012

The curious BlinkLayout

While reading the source code of Android's LayoutInflater class I found a hidden gem that seems to be quite unnoticed yet. Ladies and gentlemen I present you the mighty BlinkLayout. Views that are placed inside this ViewGroup blink at a rate of 500ms.

The BlinkLayout is an inner class of the LayoutInflater and can therefore only be used in a XML layout that will be parsed by a LayoutInflater instance. Due to the implementation it's only possible to use it as root node using the <blink> tag inside a XML layout.

It seems like the BlinkLayout is available since Android 4.0 and isn't used in the Android source code I observed. Maybe it was added for debugging reasons and was forgotten later.



The video above shows the BlinkLayout in action using the following layout XML:
main_layout.xml



The following snippet was used to inflate the layout and pass it to the activity:
BlinkLayoutActivity.java








2 comments:

  1. Interesting stuff!
    But I think this isn't useful.. as for me.
    Today made repost in my blog http://vsvydenko.blogspot.com/2012/05/curious-blinklayout-in-android.html

    ReplyDelete
    Replies
    1. Yeah, it's not really useful. It's more like an easter egg.

      So what's up with the repost thing? What's the use case of that? ;)

      Delete