Fluid/Dynamic layout in Firemonkey / Delphi

2019-02-16 23:50发布

问题:

Let's say I want two shapes on a form sitting side by side taking up exactly 50% of the window each, which resize when the window is resized. How can I do that?

What I really want is to set things up in ratios.. eg.. Have one of the above shapes take up 25% and the other take 75%

The dynamic resizing is very important, and I don't want to have to type any code to achieve this.

回答1:

Can be achieved by dropping a TLayout on the form - Setting the Align option to 'alscale'

Then adding 2 items to the TLayout I.e for my example TPanels - with align options on both set also to 'alscale'. Set the widths of each to the ratio you want.

Form On Creation:

Form On Resize:

Can be achieved with 'no code -'for the images above I just added labels to display panel widths on form resize. Hope this helps Paul