我想用firemonkey在Delphi中复制https://github.com/jdg/MBProgressHUD的HUD功能。
这就像iPhone中的样子:
主要问题是如何使表格半透明&完全删除边框。
答案 0 :(得分:4)
创建Firemonkey HD表单,将其设置为Fill.Kind
至bkNone
,将Fill.Color
设置为Null
。另外,将其Transparency
属性设置为True,将BorderStyle
设置为bsNone
。
创建一个TRectangle(或任何形状),并将Stroke.Kind
属性设置为bkNone
。将Fill.Color
设置为Gray
,将Opacity
设置为0.5。
使用两者的父级作为表单创建TAniIndicator
和TLabel
。它的Opacity
保持在1.0。或者,也可以创建TImage
并使其与TAniIndicator
的大小和位置完全相同。
从那里开始,只需要在TAniIndicator上使用TFloatAnimation
时想要更改图像(刻度线等),标签文本只需更改为要显示的任何消息。理想情况下,您只需创建一个接受字符串或整数作为变量的过程,然后修改文本和指示符/图像以匹配该过程。例如;
Procedure TForm1.Process(Mode : Integer);
Begin
if Mode = 1 then
begin
AniIndicator1.Enabled := True;
AniIndicator1.Visible := True;
Image1.Visible := False;
Label1.TextAlign := TTextAlign.taCenter; // Must be called to reset alignment
Label1.Text := 'Loading';
End
else if Mode = 2 then
Begin
AniIndicator1.Enabled := False;
AniIndicator1.Visible := False;
Label1.TextAlign := TTextAlign.taCenter; // Must be called to reset alignment
Image1.Bitmap.LoadFromFile('Tick.png');
Image1.Visible := True;
Label1.Text := 'Complete!';
end;
end;
然后,您可以在主窗体中创建一个tpanel,然后将上面的表单(包含TAniIndicator, label, and rectangle
)添加为子组件。然后,使用有效的模式变量调用您创建的过程,它将按照您在代码中指示的方式运行。添加更多模式很容易,我已经使用我自己的应用程序做了类似的事情(虽然它与TRectangle
有关,而不是创建指标。)