Anyone able to spot the issues here? When I run this and toggle between portrait and landscape it does not work as expected (re width of rectangles following changing size of the effective width)
Try to get what the basic (simple) concept/approach is to handle autosizing UI elements to support Portrait and Landscape…
display.setStatusBar( display.HiddenStatusBar ) local WIDTH\_PERCENT = 0.8 local myGroup = display.newGroup() local myRoundedRect = display.newRoundedRect(myGroup, 0,0, display.contentWidth \* WIDTH\_PERCENT, 50, 25) myRoundedRect.strokeWidth = 3 myRoundedRect:setFillColor(0,1,0) myRoundedRect:setStrokeColor(1,0,0) myRoundedRect.y = 25 local myRoundedRect2 = display.newRoundedRect(myGroup, 0,0, display.contentWidth \* WIDTH\_PERCENT, 50, 25) myRoundedRect2.strokeWidth = 3 myRoundedRect2:setFillColor(0,0,1) myRoundedRect2:setStrokeColor(1,0,0) myRoundedRect2.y = 75 local function positionItems() myRoundedRect.width = display.contentWidth \* WIDTH\_PERCENT myRoundedRect2.width = display.contentWidth \* WIDTH\_PERCENT myRoundedRect.x = display.contentWidth/2 myRoundedRect2.x = display.contentWidth/2 end positionItems() local function onOrientationChange( event ) positionItems() end Runtime:addEventListener( "orientation", onOrientationChange )