It turned out that we were reading the heights of the contols and other elements before we initialized the heights.