qGold
qGold

Reputation: 341

FMX [Android] make multiple Labels bold

I've got 5 labels on my form whose Fonts styles should all get the BOLD property added. I tried doing this using the code below but only Label2 gets bold and the rest still stays as it is at design time.

  Sleep(350);
  TThread.Synchronize(nil,
    procedure
    begin
      Label2.TextSettings.Font.Style := Label2.TextSettings.Font.Style +
        [TFontStyle.fsBold];
      Label2.TextSettings.FontColor := TAlphaColorRec.Gray;
    end);
  Sleep(350);
  TThread.Synchronize(nil,
    procedure
    begin
      Label3.TextSettings.Font.Style := Label3.TextSettings.Font.Style +
        [TFontStyle.fsBold];
      Label3.TextSettings.FontColor := TAlphaColorRec.Gray;
    end);
  Sleep(350);
  TThread.Synchronize(nil,
    procedure
    begin
      Label4.TextSettings.Font.Style := Label4.TextSettings.Font.Style +
        [TFontStyle.fsBold];
      Label4.TextSettings.FontColor := TAlphaColorRec.Gray;
    end);
  Sleep(350);
  TThread.Synchronize(nil,
    procedure
    begin
      Label5.TextSettings.Font.Style := Label5.TextSettings.Font.Style +
        [TFontStyle.fsBold];
      Label5.TextSettings.FontColor := TAlphaColorRec.Gray;
    end);
  Sleep(350);
  TThread.Synchronize(nil,
    procedure
    begin
      Label6.TextSettings.Font.Style := Label6.TextSettings.Font.Style +
        [TFontStyle.fsBold];
      Label6.TextSettings.FontColor := TAlphaColorRec.Gray;
    end);
  Sleep(350);

The colors change on each Label, but the Fonts aren't getting bold except for the first label which I try to get bold... this is confusing me. please help me. I use Delphi 10.3.3 Community Edition and an Android 10 Smartphone (Lineage 17.1)

Upvotes: 1

Views: 472

Answers (1)

Tom Brunberg
Tom Brunberg

Reputation: 21033

For all labels, for which you want to manipulate the Style property, you need to remove the Style setting from StyledSettings.

(As the color change works, you already removed the FontColor setting from StyledSettings)

Actually, if you set any of these settings at design time, the IDE removes the corresponding StyledSetting. If you don't change any of these settings at design time, you must remove the corresponding StyledSettings before you can change the setting at runtime.

Upvotes: 1

Related Questions