View Hierarchy

We only do what’s absolutely necessary in a custom View. We don’t want to reinvent the wheel. The images, the static part should be done in an Android Widget. Our xml structure is the following:

The main layout hierarchy

As you see we have a hardcoded aspect ratio of 360:460. This is the size of the VectorDrawables. As long as we keep the views in this fixed aspect ratio we are good to go.

We’ll focus on the LightsShaderView today so lets get rid of the others:

Let’s focus on one light only

The Data Classes

First we need to know where are the rooms, more precisely where are the walls. I don’t think the apartment structure will change in the near future, so I hardcoded the coordinates into Firebase for now. It’s fairly easy to extract the object coordinates from the VectorDrawable. We need to know where are the lights too, so at the end of the day we have something like this to use: