Best way to scale a multi-panel UI?
Posted: 01 Jul 2015, 19:15
This is for an iOS and Android app.
The image below shows the approximate layout. There is a top panel, a bottom panel, and the middle area is transparent (gameplay is seen in this area).
Each panel has an outline on three sides, and contains a number of static and dynamic elements e.g. circular buttons, text boxes, progress bars etc.
The panels should stretch to fit whatever device we are running on. The space between the top and bottom panels should maintain its current aspect ratio. The contents of each panel should also maintain their aspect ratio. i.e. the panels should fill the width of the screen, the circles should stay circular and the boxes remain square.
Question 1: What is the best way to code this in XAML so it scales correctly?
I understand that a Viewbox will scale to fill, but how do I make sure that the border of the panel stays a constant width (not fatter in whichever direction the panel has been scaled), and the components keep their aspect ratio?
This is an example of what we don't want:
Question 2: Both the top and bottom panels can be expanded vertically by the player (they drag down on the edge of the panel). They would do this to see additional information. When the panel is expanded, new components appear and existing ones move to a new position (they don't scale).
What is the best way to scale the panel so that the outline remains a constant width and the components stay the same size? For the outline, would it be best to form it as two pieces with the vertical lines as one piece and the bottom as a second piece and scale the vertical lines but move the horizontal line?
Please keep in mind how things are set up as per Question 1.
The image below shows the approximate layout. There is a top panel, a bottom panel, and the middle area is transparent (gameplay is seen in this area).
Each panel has an outline on three sides, and contains a number of static and dynamic elements e.g. circular buttons, text boxes, progress bars etc.
The panels should stretch to fit whatever device we are running on. The space between the top and bottom panels should maintain its current aspect ratio. The contents of each panel should also maintain their aspect ratio. i.e. the panels should fill the width of the screen, the circles should stay circular and the boxes remain square.
Question 1: What is the best way to code this in XAML so it scales correctly?
I understand that a Viewbox will scale to fill, but how do I make sure that the border of the panel stays a constant width (not fatter in whichever direction the panel has been scaled), and the components keep their aspect ratio?
This is an example of what we don't want:
Question 2: Both the top and bottom panels can be expanded vertically by the player (they drag down on the edge of the panel). They would do this to see additional information. When the panel is expanded, new components appear and existing ones move to a new position (they don't scale).
What is the best way to scale the panel so that the outline remains a constant width and the components stay the same size? For the outline, would it be best to form it as two pieces with the vertical lines as one piece and the bottom as a second piece and scale the vertical lines but move the horizontal line?
Please keep in mind how things are set up as per Question 1.