How to Create a Custom Lock Screen for Android (Part II)


In the previous tutorial, I introduced you to a few important source files that belong to AOSP’s default lock screen and system UI. Today, let’s take a look at a few more of such files. You’ll see that many of these files contain highly-focused code and are designed to perform very specific actions. It does get a little frustrating to open a new class to understand every little detail, but I hope you can appreciate the modularity AOSP’s developers have achieved.


As its name suggests, this is a very important part of both the lock screen and the status bar. It is the container for almost everything that’s displayed in both. Let us now take a look at some of the most important custom layout widgets it contains:

This widget is responsible for displaying the album art associated with any music file that’s playing on the device while it’s locked. As you might’ve seen, it displays the album art behind the notifications.

This is the widget that renders the dim gray semi-transparent color that’s displayed on the lock screen and when the status bar is swiped down. It has an exclusion area on which the color is not drawn. The exclusion area is mainly behind the notifications.

This is a view whose hasOverlappingRendering function is set to false–a performance optimization. In essence, setting hasOverlappingRendering to false prevents a view from creating a layer when its alpha is animating.


This layout file is included in the super_status_bar.xml file, and accounts for a large chunk of the lock screen’s layout, and, of course, the layout that’s rendered when you swipe down on the status bar. Yes, the same layout is used by both.

This is a custom layout widget that’s responsible for displaying the notifications. Because it has nearly 5000 lines of code, understanding it fully requires quite a lot of patience and effort. Additionally, this widget is very tightly coupled with other parts of the SystemUI package, and, as a result, cannot be used independently.

This class decides which layout XML file to use for a notification. The available options include media notification, big picture notification, and big text notification.

This widget actually draws the notification’s background, be it dimmed or normal. It seems to be used only on the lock screen.

Don’t let the name fool you. This class belongs to the SystemUI package! Its name might sound weird, but this is the class that’s responsible for handling the shortcuts(for the camera and phone) on the lock screen. It also contains code to draw the white animated circle when the user touches those shortcuts. Of course, it uses the ValueAnimator class extensively to manage the radius of the circle.

To be continued…

If you found this article useful, please share it with your friends and colleagues!