One solution is to wait until after the first resize event before drawing the layout.
You can do this by adding
#if b4j
Wait For b4xPage_resize (Width As Int, Height As Int)
#end if
right after Root = Root1
There are probably other ways to solve this.