delphi Firemonkey ListBoxItem自绘

ListBoxItem1的事件ListBoxItem1Paint

procedure TForm1.ListBoxItem1Paint(Sender: TObject; Canvas: TCanvas; const ARect: TRectF);
begin
if (Sender as TListBoxItem).IsSelected then
begin
Canvas.Fill.Kind := TBrushKind.Solid;
Canvas.Fill.Color := TAlphaColorRec.Blue;
Canvas.FillRect(ARect, , , [], ); Canvas.Fill.Kind := TBrushKind.Solid;
Canvas.Fill.Color := TAlphaColorRec.White;
Canvas.FillText(ARect, (Sender as TListBoxItem).Text, False, , [], TTextAlign.Leading, TTextAlign.Center);
end
else
begin
Canvas.Fill.Kind := TBrushKind.Solid;
Canvas.Fill.Color := TAlphaColorRec.White;
Canvas.FillRect(ARect, , , [], ); Canvas.Fill.Color := TAlphaColorRec.Black;
Canvas.Fill.Kind := TBrushKind.Solid;
Canvas.FillText(ARect, (Sender as TListBoxItem).Text, False, , [], TTextAlign.Leading, TTextAlign.Center);
end;
end;
05-16 19:28