Making a Responsive UI with UI Toolkit
In this section, we are going to learn how to make the UI we created previously adapt to different screen sizes. We are going to discuss the following concepts:
- Dynamic positioning
- Dynamic scaling
- Using relative positions
Let's start by discussing how we can make the position and size of our objects to adapt the screen size.
Dynamic positioning and sizing
So far, we have used the Left and Top Position attributes to specify the X and Y position of our elements with respect to the top-left corner of the screen, and then Width and Height to define the Size. While essentially, that is all that's needed to define an object position and size, it is not very useful in all cases, especially when we need to adapt to different screen sizes.
In the example, if you need to place an object in the top-right corner of the screen, knowing its size is 100x100 pixels, and the screen size is 1920x1080 pixels, we can put...