结果:
1.加载图片很流畅,可以做背景用。
2.现在是加载了正形与圆形,其他形状能不能加载呢?自己测试哦,要多动手才行。
3.需要把图片打到包里哦(路径为“assets\internal\”)。
实例代码:
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.Objects,
FMX.Controls.Presentation, FMX.StdCtrls; type
TForm1 = class(TForm)
Button1: TButton;
Rectangle1: TRectangle;
Label1: TLabel;
Ellipse1: TEllipse;
Button2: TButton;
Label2: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end; var
Form1: TForm1; implementation
uses
system.IOUtils;//需要引入
{$R *.fmx}
{$R *.NmXhdpiPh.fmx ANDROID} procedure TForm1.Button1Click(Sender: TObject);
begin
Rectangle1.Width := ;
Rectangle1.Height := ;
Rectangle1.Stroke.Kind := TBrushKind.bkNone; //边框类型,无
Rectangle1.Fill.Kind := TBrushKind.bkBitmap; //填充类型,图片
Rectangle1.Fill.Bitmap.WrapMode := TWrapMode.wmTileStretch; //拉伸
Rectangle1.Fill.Bitmap.Bitmap.LoadFromFile(TPath.Combine(TPath.GetDocumentsPath, '144.jpg'));
end; procedure TForm1.Button2Click(Sender: TObject);
begin
Ellipse1.Width := ;
Ellipse1.Height := ;
Ellipse1.Stroke.Kind := TBrushKind.bkNone; //边框类型,无
Ellipse1.Fill.Kind := TBrushKind.bkBitmap; //填充类型,图片
Ellipse1.Fill.Bitmap.WrapMode := TWrapMode.wmTileStretch; //拉伸
Ellipse1.Fill.Bitmap.Bitmap.LoadFromFile(TPath.Combine(TPath.GetDocumentsPath, '144.jpg'));
end; end.