Search code examples
delphifiremonkeydelphi-10.1-berlin

How to style buttons in Firemonkey


Are there special steps for styling a button using stylebook in FMX? because whenever I change my style it works in the viewer only, however when I run the program nothing changes although stylebook setting are properly connected to style files and to the application as well, also if I close the program and start it again I find the same style saved and exists in the view but when run the application I cant find any style, can anyone tell me the exact steps? because I check tutorials, docs, help but still stylebook wont apply the new changes to the app at run time. Thanks.

Screenshot


Solution

  • To modify the default style:

    1. Start with a blank fmx form and add a TButton.

    2. Right-Click on the button and select Edit Default Style ... - the Style Designer opens

    3. In the Structure pane select Buttonstyle - text

    4. In the Object Inspector change the NormalColor property to Crimson. The text of the button changes to Crimson (red) color.

    5. Hit the designer view Close button (X) and confirm to Apply changes ... by clicling Yes when prompted. Note that a Stylebook has been added to the form.

    6. Build and run

    The result looks like this on Windows 7

    enter image description here

    Maybe you have omitted step 5 (just guessing)

    With an existing stylebook and style do as follows:

    1. Start with a blank fmx form and add a TButton.

    2. Add a TStyleBook, set its UseStyleManager property, double-click it and load an existing style (e.g. Air)

    3. In the structure pane select buttonstyle - text. Note that available properties are not necessarily the same as when editing the default style.

    4. In the Object Inspector change the Font - FontColor property to Yellow. The text of the button changes to yellow color.

    5. Hit the designer view Close button (X) and confirm to Apply changes ... by clicling Yes when prompted.

    6. Build and run

    The result looks like this on Windows 7

    enter image description here