How To Set a FMX.Panel Color?

Bill picture Bill · Sep 14, 2013 · Viewed 17.6k times · Source

FMX controls do not have a color property. What is the FMX equivalent to VCL.TColor?

FMX.Panel1.Color := clBlack

Answer

Chris Rolliston picture Chris Rolliston · Sep 14, 2013

Quoting myself: in a nutshell, use a TRectangle instead of a TPanel (a panel's style is probably composed of a TRectangle anyway):

  1. Add a TRectangle to the form.
  2. Change Stroke.Color to Gray.
  3. Change Fill.Color to whatever you want.
  4. At runtime, change the colour with code like this:

MyRectangle.Fill.Color := TAlphaColors.Blue;

Annoyingly, at designtime, a TRectangle is made to pretend it can’t parent other controls (in reality, any FMX control can parent any other). However, you can use the Structure pane top left of the IDE to reparent controls to it as you wish.