One rather annoying aspect of FMX’s evolution has been a restriction on control sizes. The most notorious case is probably TGroupBox, which in XE4′s iOS support was bizarrely matched to Safari’s toolbar (i.e., a standard control with a non-standard height), rendering the thing useless. Nevertheless, the general rationale for fixed sizing is not ridiculous – different platforms have different standard sizes for buttons, toolbars and so forth, so it makes sense for FMX to assist the developer in ensuring these conventions are respected. Even so, the implementation taken has been distinctly sub-optimal in my view – in particular, I would have much preferred an AutoSize property that defaults to True. As things stand, standard sizes are instead hardcoded in internal style code and trump even the Align property.
For example, here’s a right-aligned TSpeedButton with its StyleLookup set to ‘composetoolbutton’ and parented to a TListBoxItem, running on an Android tablet. I’ve taken the screenshot as I am pressing the button down – notice how this clearly shows it to be taller than its parent:
Happily, this dubious behaviour can be prevented by overriding the control’s AdjustFixedSize method however. To implement this fix in the form of an interposer class, declare the following immediately before the form type:
type TSpeedButton = class(FMX.StdCtrls.TSpeedButton) protected procedure AdjustFixedSize(const Ref: TControl); override; end;
Next, implement the method like so:
procedure TSpeedButton.AdjustFixedSize(const Ref: TControl); begin SetAdjustType(TAdjustType.None); end;
Fix added, a speed button’s Align property will now be properly respected: