Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How To Set a FMX.Panel Color?

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

FMX.Panel1.Color := clBlack

like image 274
Bill Avatar asked Sep 14 '13 15:09

Bill


2 Answers

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.

like image 81
Chris Rolliston Avatar answered Nov 13 '22 23:11

Chris Rolliston


I found a better way : -define the panel as needed -put all necessary controls inside it -add in it a Rectangle of the same size as the panel -set its Fill Property to the colour you want -send the rectangle to the back so other controls will be visible

This way, it looks like the panel has a Fill colour, but it functions as a panel, e.g. all controls within it can be made not visible at the same time, etc.

like image 2
GentilBarbuLux Avatar answered Nov 13 '22 22:11

GentilBarbuLux