在运行时添加Delphi XE6 firemonkey组件对齐问题

时间:2014-07-08 07:48:08

标签: ios delphi alignment firemonkey delphi-xe6

我想在我的iOS应用程序中动态添加5个TLable。

像这样

Procedure Form1.FormCreate(Sender: TObject)
var
  I: Integer;
begin
  for I := 1 to 5 do
  begin
    with TLabel.Create(Self) do
    begin
      Parent := self;
      Align := TAlignLayout.Top;
      Height := 50;
      Text := IntToStr(I);
    end;
  end;
end;

我认为订单是12345,但我得到15432。

我可以做些什么来获得理想的结果?

1 个答案:

答案 0 :(得分:1)

您必须有机会使用对齐算法来执行您想要的操作。

procedure TForm1.FormCreate(Sender: TObject);
var
  I: Integer;
begin
  for I := 1 to 5 do
  begin
    with TLabel.Create(Self) do
    begin
      Parent := self;
      Align := TAlignLayout.alTop;
      Height := 50;
      Position.Y := I*Height; //add this line
      Text := IntToStr(I);
    end;
  end;
end;
相关问题