yangyxd / FMXUI

FMX跨平台基础UI库
MIT License
262 stars 99 forks source link

TListViewEx + FontSize #54

Open kazuser opened 1 year ago

kazuser commented 1 year ago

Could you please tell me how to fix it? FontsSize is too small ("1" or "2") by default 😕

image

KngStr commented 1 year ago

By default it will use the default font. If you just type this code in the picture, it's weird. We need a sample.

Another way you can chagne the font like this


type
  TMyStringsListCheckAdapter = class(TStringsListCheckAdapter)
  protected
    function GetView(const Index: Integer; ConvertView: TViewBase; Parent: TViewGroup): TViewBase; override;
  end;

{ TMyStringsListCheckAdapter }

function TMyStringsListCheckAdapter.GetView(const Index: Integer;
  ConvertView: TViewBase; Parent: TViewGroup): TViewBase;
var
  ViewItem: TListViewItemCheck;
begin
  Result := inherited;

  // just when first create
  if (ConvertView = nil) or (not (ConvertView is TListTextItem)) then begin
    ViewItem := TListViewItemCheck(Result);
    ViewItem.TextView1.TextSettings.Font.Size := 24;
  end;
end;

procedure TFrameListViewTest.DoShow;
var
  I: Integer;
  Adapter: TMyStringsListCheckAdapter;
begin
  inherited;

  Adapter := TMyStringsListCheckAdapter.Create(nil);
  Adapter.SetArrayLength(1000);
  for I := 0 to Adapter.Count - 1 do
    Adapter.Items[I] := Format('test list item %d', [I]);
  ListViewEx1.Adapter := Adapter;
end;

Test unit from FMXUI\demos\standard\uFrameListViewTest.pas: