I am creating an isometric map with simple tiles, and I’ve extended RelativeLayout
to create a layout that holds these tiles. Really, just using a R
OK, figured it out by looking at the Android source code. I had the mapping of getChildDrawingOrder
: the i
passed is “which child should I draw i th?” not "when should I draw child i?" The reason for the NULL
s is because those children were being drawn before their own i
was passed.
I changed my code to figure out the order for all children during the onMeasure
pass, saving that in a SparseIntArray
, and then just returned that from getChildDrawingOrder
. This works.
Back-calculating the index in the getChildDrawingOrder
function, by the way, is a bad idea unless you want to rely on the order in which the children are declared. Because if you don’t rely on that order, you have to walk through the list of children to find the one that has the appropriate x and y values, which means you have to walk through the list of children for each child. That’s an O(n²) operation (read: fairly inefficient). The mathematics are also reasonably complicated.