0

I want to change the default Font in Listview TTextObjectAppearance, when I run it on windows it works fine but when I run it mobile it does not show the Font I select.

.fmx

object Form1: TForm1
  Left = 0
  Top = 0
  Caption = 'Form1'
  ClientHeight = 480
  ClientWidth = 321
  FormFactor.Width = 320
  FormFactor.Height = 480
  FormFactor.Devices = [Desktop]
  DesignerMasterStyle = 0
  object DomainsListView: TListView
    ItemAppearanceClassName = 'TDynamicAppearance'
    ItemEditAppearanceClassName = 'TDynamicAppearance'
    HeaderAppearanceClassName = 'TListHeaderObjects'
    FooterAppearanceClassName = 'TListHeaderObjects'
    Align = Client
    Size.Width = 321.000000000000000000
    Size.Height = 480.000000000000000000
    Size.PlatformDefault = False
    TabOrder = 1
    ItemAppearance.ItemHeight = 58
    ItemAppearanceObjects.ItemObjects.ObjectsCollection = <
      item
        AppearanceObjectName = 'domain'
        AppearanceClassName = 'TTextObjectAppearance'
        Appearance.Font.Family = 'Algerian'
        Appearance.Font.Size = 19.000000000000000000
        Appearance.Font.StyleExt = {00070000000000000004000000}
        Appearance.TextAlign = Leading
        Appearance.WordWrap = True
        Appearance.TextColor = claNavy
        Appearance.Trimming = Word
        Appearance.Width = 209.000000000000000000
        Appearance.Height = 29.000000000000000000
        Appearance.Align = Center
        Appearance.VertAlign = Center
        Appearance.PlaceOffset.X = 7.000000000000000000
        Appearance.PlaceOffset.Y = -12.000000000000000000
      end
      item
        AppearanceObjectName = 'expiry'
        AppearanceClassName = 'TTextObjectAppearance'
        Appearance.Font.Family = 'Algerian'
        Appearance.Font.Size = 17.000000000000000000
        Appearance.TextAlign = Leading
        Appearance.TextColor = xFFF1490B
        Appearance.Width = 209.000000000000000000
        Appearance.Height = 24.000000000000000000
        Appearance.Align = Center
        Appearance.VertAlign = Center
        Appearance.PlaceOffset.X = 8.000000000000000000
        Appearance.PlaceOffset.Y = 14.000000000000000000
      end
      item
        AppearanceObjectName = 'image'
        AppearanceClassName = 'TImageObjectAppearance'
        Appearance.Width = 31.000000000000000000
        Appearance.Height = 32.000000000000000000
        Appearance.PlaceOffset.X = 8.000000000000000000
        Appearance.PlaceOffset.Y = 16.000000000000000000
      end>
    ItemAppearanceObjects.ItemEditObjects.ObjectsCollection = <
      item
        AppearanceObjectName = 'Text1'
        AppearanceClassName = 'TTextObjectAppearance'
      end>
    ItemAppearanceObjects.FooterObjects.Text.Width = 233.000000000000000000
    ItemAppearanceObjects.FooterObjects.Text.Height = 24.000000000000000000
    ItemAppearanceObjects.FooterObjects.Text.PlaceOffset.X = 80.000000000000000000
    StyleLookup = 'DomainsListViewStyle1'
    object FilterPanelRect: TRectangle
      Align = Client
      Fill.Color = xFF2AB39C
      Margins.Left = 25.000000000000000000
      Margins.Top = 8.000000000000000000
      Margins.Right = 25.000000000000000000
      Margins.Bottom = 100.000000000000000000
      Size.Width = 300.000000000000000000
      Size.Height = 407.000000000000000000
      Size.PlatformDefault = False
      Stroke.Color = xFF23917E
      Stroke.Thickness = 5.000000000000000000
      Visible = False
      object HeaderFilterPanelRect: TRectangle
        Align = Top
        Fill.Color = xFF2B2A38
        Size.Width = 300.000000000000000000
        Size.Height = 41.000000000000000000
        Size.PlatformDefault = False
        Stroke.Kind = None
        object HeaderFilterPanelLabel: TLabel
          Align = Client
          StyledSettings = [Family, Style]
          Margins.Left = 5.000000000000000000
          Margins.Top = 5.000000000000000000
          Margins.Right = 5.000000000000000000
          Margins.Bottom = 5.000000000000000000
          Size.Width = 290.000000000000000000
          Size.Height = 31.000000000000000000
          Size.PlatformDefault = False
          StyleLookup = 'toollabel'
          TextSettings.Font.Size = 18.000000000000000000
          TextSettings.FontColor = claWhite
          TextSettings.HorzAlign = Center
          Text = 'Select Filter'
          TabOrder = 0
        end
      end
    end
    object Edit1: TEdit
      Touch.InteractiveGestures = [LongTap, DoubleTap]
      TabOrder = 1
      Position.X = 144.000000000000000000
      Position.Y = 352.000000000000000000
      Size.Width = 185.000000000000000000
      Size.Height = 30.000000000000000000
      Size.PlatformDefault = False
      Visible = False
    end
    object Edit2: TEdit
      Touch.InteractiveGestures = [LongTap, DoubleTap]
      TabOrder = 2
      Position.X = 144.000000000000000000
      Position.Y = 384.000000000000000000
      Size.Width = 185.000000000000000000
      Size.Height = 30.000000000000000000
      Size.PlatformDefault = False
      Visible = False
    end
    object Edit3: TEdit
      Touch.InteractiveGestures = [LongTap, DoubleTap]
      TabOrder = 3
      Position.X = 144.000000000000000000
      Position.Y = 416.000000000000000000
      Size.Width = 185.000000000000000000
      Size.Height = 30.000000000000000000
      Size.PlatformDefault = False
      Visible = False
    end
    object Edit4: TEdit
      Touch.InteractiveGestures = [LongTap, DoubleTap]
      TabOrder = 4
      Position.X = 144.000000000000000000
      Position.Y = 448.000000000000000000
      Size.Width = 185.000000000000000000
      Size.Height = 30.000000000000000000
      Size.PlatformDefault = False
      Visible = False
    end
    object StringGrid1: TStringGrid
      Align = Client
      CanFocus = True
      ClipChildren = True
      Size.Width = 350.000000000000000000
      Size.Height = 520.000000000000000000
      Size.PlatformDefault = False
      TabOrder = 7
      Visible = False
      RowCount = 0
      Viewport.Width = 346.000000000000000000
      Viewport.Height = 495.000000000000000000
    end
    object Button1: TButton
      Position.X = 224.000000000000000000
      Position.Y = 248.000000000000000000
      TabOrder = 8
      Text = 'Button1'
      OnClick = Button1Click
    end
  end
end

.pas

unit Unit1;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,
  FMX.ListView.Types, FMX.ListView.Appearances, FMX.ListView.Adapters.Base,
  System.Rtti, FMX.Grid.Style, FMX.ScrollBox, FMX.Grid, FMX.Edit,
  FMX.Controls.Presentation, FMX.StdCtrls, FMX.Objects, FMX.ListView;

type
  TForm1 = class(TForm)
    DomainsListView: TListView;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.fmx}

procedure TForm1.Button1Click(Sender: TObject);
var
  LItem: TListViewItem;
   begin
     LItem := DomainsListView.Items.Add;
      LItem.Data['domain'] := 'Stackoverflow.com';
      LItem.Data['expiry'] := datetimetostr(now);
   end;
end.

I have updated the post and I have added the code of the .pas and .fmx files.

Ian Boyd
  • 246,734
  • 253
  • 869
  • 1,219
MrSiMo
  • 101
  • 7
  • Please include `.fmx` and `.pas` files for a complete, [mre] so the problem can be replicated. – Tom Brunberg Apr 15 '22 at 06:24
  • 1
    On Android to change the font you have to include it in the project, then assign it to the item at runtime – mino Apr 15 '22 at 11:09
  • @Tom-Brunberg I have added links to the files .pas and .fmx mino please could you tell me how? – MrSiMo Apr 18 '22 at 23:05
  • You need to add the ".ttf" font file in the "Deployment" window, then Set "Remote Path" to ". \ Assets \ internal \". At runtime, to load a font in a component such as "TLabel" just select as follows: "Label1.TextSettings.Font.Family: = 'yourfont'" (without the path, respecting the case) – mino Apr 19 '22 at 09:08

0 Answers0