Skip to content

When using FMX for Android development, if I use FrameStand, the dynamically created frames inside a TScrollBox do not scroll. #89

@reshith

Description

@reshith

When using FMX for Android app development, if I use FrameStand, the dynamically created frames inside a TScrollBox do not scroll.
There is no issue when built for Windows application.

unit Frames.Item;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Graphics, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.StdCtrls, FMX.Objects,
  Generics.Collections
  ;

type
  TItemFrame = class(TFrame)
    Rectangle1: TRectangle;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

type
  TItemFrameList = class(TList<TItemFrame>)
  private
    { Private declarations }
  protected
    procedure Notify(const Item: TItemFrame; Action: TCollectionNotification); override;
  public
    { Public declarations }
  end;

implementation

{$R *.fmx}

{ TItemFrameList }

procedure TItemFrameList.Notify(const Item: TItemFrame; Action: TCollectionNotification);
begin
  case Action of
    cnAdding:
      begin
      end;
    cnAdded:
      begin
      end;
    cnExtracting:
      begin
      end;
    cnExtracted:
      begin
      end;
    cnDeleting:
      begin
        // if Assigned(Item) then
        // Item.Free;
      end;
    cnRemoved:
      begin
        // if Assigned(Item) then
        // Item.Free;
      end;
  end;

  inherited;
end;

end.
unit Frames.ScrollBox;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Graphics, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.StdCtrls, FMX.Layouts,
  Generics.Collections,
  Frames.Item;

type
  TScrollBoxFrame = class(TFrame)
    RootLayout: TGridPanelLayout;
    ItemListScrollBox: TVertScrollBox;
  private
    { Private declarations }
    FItemFrameList: TList<TItemFrame>;
  public
    { Public declarations }
    constructor Create(AOwner: TComponent); reintroduce; override;
    destructor Destroy(); override;

    [BeforeShow]
    procedure OnBeforeShow;
    // [AfterShow]
    // procedure OnAfterShow;
    [BeforeClose]
    procedure OnBeforeClose();
  end;

implementation

{$R *.fmx}

{ TScrollBoxFrame }

constructor TScrollBoxFrame.Create(AOwner: TComponent);
begin
  inherited;

  FItemFrameList := TList<TItemFrame>.Create;

  var
    LTop: Single := 0;
  for var I := 0 to 4 do
  begin
    var
    LItemFrame := TItemFrame.Create(ItemListScrollBox);
    with LItemFrame do
    begin
      Name := 'ItemFrame' + I.ToString + FormatDateTime('HHNNSSZZZ', Now);
      Parent := ItemListScrollBox;
      Align := TAlignLayout.Horizontal;
      LItemFrame.Position.Y := LTop;
      Visible := True;
    end;
    FItemFrameList.Add(LItemFrame);

    LTop := LTop + LItemFrame.Height;
  end;
end;

destructor TScrollBoxFrame.Destroy;
begin
  if Assigned(FItemFrameList) then
  begin
    FreeAndNil(FItemFrameList);
  end;

  inherited;
end;

procedure TScrollBoxFrame.OnBeforeClose;
begin

end;

procedure TScrollBoxFrame.OnBeforeShow;
begin

end;

end.
unit Forms.Main;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, SubjectStand,
  Frames.ScrollBox,
  FrameStand;

type
  TMainForm = class(TForm)
    FrameStand1: TFrameStand;
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  MainForm: TMainForm;

implementation

{$R *.fmx}


procedure TMainForm.FormShow(Sender: TObject);
begin
  var
  LFrameInfo := FrameStand1
    .GetFrameInfo<TScrollBoxFrame>(True, nil, '');
  var
  LFrame := LFrameInfo.Frame;
  LFrame.OnBeforeShow();

  LFrameInfo.Show();
end;

end.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions