Может быть вам пригодится - мой пример векторного подхода к AniIndicator без использования картинок и для различных разрешений экрана.
Для отрисовки дуги использовал компонент Равиля на основе FMX.Graphics.Native, поскольку стандартные функции не красиво рисуют под Андроидом.
Сам индикатор:
unit newaniindicator;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Ani,
FMX.Objects, FMX.Layouts, FMX.ZNativeDrawFigure;
type
TNewAniIndicator = class(TZNativeDrawFigureArc)
Animation: TFloatAnimation;
procedure AnimationProcess(Sender: TObject);
procedure AnimationFinish(Sender: TObject);
procedure IndicatorResize(Sender: TObject);
procedure Start;
procedure Stop;
Constructor Create(AOwner: TComponent); override;
Destructor Destroy; override;
private
active: boolean;
public
colors: array of TAlphaColor;
end;
implementation
constructor TNewAniIndicator.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
Fill.Kind:=TBrushKind.None;
Stroke.Cap:=TStrokeCap.Round;
Stroke.Join:=TStrokeJoin.Round;
Animation:=TFloatAnimation.Create(Self);
with Animation do begin
Parent:=Self;
Duration:=1;
StartValue:=-90;
StopValue:=270;
PropertyName:='StartAngle';
Interpolation:=TInterpolationType.Quadratic;
OnProcess:=AnimationProcess;
OnFinish:=AnimationFinish;
end;
OnResize:=IndicatorResize;
end;
destructor TNewAniIndicator.Destroy;
begin
Animation.Free;
inherited;
end;
procedure TNewAniIndicator.IndicatorResize(Sender: TObject);
begin
Stroke.Thickness:=Width*0.1;
end;
procedure TNewAniIndicator.Start;
begin
active:=true;
Stroke.Color:=colors[0];
Visible:=true;
Animation.Start;
end;
procedure TNewAniIndicator.Stop;
begin
active:=false;
Visible:=False;
Animation.Stop;
end;
procedure TNewAniIndicator.AnimationProcess(Sender: TObject);
begin
EndAngle:=-0.0037*sqr(StartAngle)+0.667*StartAngle+90; //Функция сжатия/растяжения дуги
end;
procedure TNewAniIndicator.AnimationFinish(Sender: TObject);
var i: byte;
begin
if active then begin
i:=0; while colors[i] <> Stroke.Color do inc(i);
if i=length(colors)-1 then Stroke.Color:=colors[0] else Stroke.Color:=colors[i+1];
Animation.Start;
end;
end;
end.
Далее в программе:
ani:=TNewAniIndicator.Create(form1);
with ani do begin
Parent:=Form1;
Width:=Form1.Width*0.2;
Height:=Width;
setlength(colors,6);
colors[0]:=TAlphaColors.Red;
colors[1]:=TAlphaColors.Orange;
colors[2]:=TAlphaColors.Yellow;
colors[3]:=TAlphaColors.Green;
colors[4]:=TAlphaColors.Blue;
colors[5]:=TAlphaColors.Violet;
Start;
end;
newaniindicator.zip