How to rotate an object and respect the Align to Client property in firemonkey

  

I am going to use a Switch to make the point more obvious. This applies to any component.

Say you have a Layout in a form (Layout1) and you drop a switch (switch1) in layout1. Set the property of the switch like this

Switch1.Align:=Client;

By default, switch1 occupies the full space of Layout1. Now, execute the following code:

Switch1.RotationAngle:=90;

This will rotate the switch but the actual component doesn’t change dimensions. FMX rotates the visual part only. This means that the Client alignment is not respected visually.

I tried to adjust the dimensions of the switch but need to turn the Client alignment off.

Switch1.Align:=TAlignLayout.None;
Switch1.Width:=Layout1.Height;
Switch1.Height:=Layout1.Width;
Switch1.RotateAngle:=90;

Anyway, this code doesn’t work either as it doesn’t follow any changes due to form resize.

So, my question is how do I make a component respect the Align property when rotated?

Any ideas?

Thank you in advance.

Comments are closed.