简体   繁体   English

在平台上绘制形状笔划的问题 Android

[英]Issues drawing the stroke of shapes on platform Android

I am new to Android app development using Delphi 11 and FMX framework.我是使用 Delphi 11 和 FMX 框架进行 Android 应用程序开发的新手。

I wanted to use a rectangle with frame as a style for a panel and wonder about how the frames of rectangles with rounded corners and other shapes are drawn on platform Android (see image).我想使用带框架的矩形作为面板的样式,想知道如何在平台 Android 上绘制带圆角和其他形状的矩形框架(见图)。 On Windows everything works as expected.在 Windows 上一切正常。 For fills, I have not been able to find any drawing error on Android so far.对于填充,到目前为止,我还没有在 Android 上发现任何绘图错误。

With rectangles, the corners are deformed and the frame is sometimes not closed.对于矩形,角会变形并且框架有时不会闭合。

Generally, for all shapes ( TCircle , TArc ) no gradient is drawn for the frame and drawing is done without antialiasing.通常,对于所有形状( TCircleTArc ),不会为框架绘制渐变,并且在没有抗锯齿的情况下完成绘制。

Since I am new, it is difficult for me to assess the problem.由于我是新手,所以我很难评估这个问题。 Is this a known and unsolvable problem of the FMX framework?这是 FMX 框架的一个已知且无法解决的问题吗? Or is this a special problem of Delphi 11?或者这是 Delphi 11 的特殊问题? Is there any other drawing problem especially on Android?是否还有其他绘图问题,尤其是在 Android 上?

Is there an alternative to draw a rectangle with rounded corners under Android?在 Android 下是否可以绘制圆角矩形? I can only think of bitmaps here.我在这里只能想到位图。

I would be very grateful if an experienced Delphi FMX developer could say something on the subject.如果有经验的 Delphi FMX 开发人员可以就此主题发表意见,我将不胜感激。

Create a new blank multi-device FMX app using Delphi 11. Drag a TRectangle onto the form.使用 Delphi 创建一个新的空白多设备 FMX 应用程序 11. 将一个 TRectangle 拖到窗体上。 Paste the following code into the form:将以下代码粘贴到表单中:

procedure TForm13.FormCreate(Sender: TObject);
begin
  Rectangle.Fill.Kind:=TBrushKind.None;
  Rectangle.XRadius:=10;
  Rectangle.YRadius:=10;
  Rectangle.Stroke.Kind:=TBrushKind.Gradient;
  Rectangle.Stroke.Thickness:=10;
  Rectangle.Stroke.Gradient.Color:=TAlphaColors.Black;
  Rectangle.Stroke.Gradient.Color1:=TAlphaColors.White;
end;

Launch the app on platform Windows and on an Android tablet.在平台 Windows 和 Android 平板电脑上启动应用程序。 Take a screenshot on both systems.在两个系统上截屏。 Why is the graphical representation different?为什么图形表示不同?

安卓/Windows 比较

As of Delphi 11 gradient brushes in strokes are not supported for Android.从 Delphi 开始,Android 不支持 11 种渐变笔刷。 This is not an official statement from Embarcadero but can be observed by browsing the source code responsible for rendering shapes on Android.这不是 Embarcadero 的官方声明,但可以通过浏览 Android 上负责渲染形状的源代码来观察。 By looking at FMX.StrokeBuilder.pas you will find no use of Gradient property of Brush and it uses the solid color always.通过查看FMX.StrokeBuilder.pas ,你会发现Brush没有使用Gradient属性,它总是使用纯色。 This was already reported on Embarcadero offical bug tracker but seems like there is not enough demand to have this fixed/implemented.已经在 Embarcadero 官方错误跟踪器上进行了报告,但似乎没有足够的需求来修复/实施此问题。

As for the deformed rounded corners this is another issue with how FMX renders curved lines on Android.至于变形的圆角,这是 FMX 如何在 Android 上渲染曲线的另一个问题。 This was also already reported and is waiting for solution.这也已经被报告并正在等待解决方案。

Late but I am a newbie here.晚了,但我是这里的新手。 I ran in this problem long time ago and use RadiantShapes.TRadiantRectangle instead of TRectangle.我很久以前遇到过这个问题,使用 RadiantShapes.TRadiantRectangle 而不是 TRectangle。 Another solution is to use TPath (FMX.Objects one)另一种解决方案是使用 TPath (FMX.Objects one)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM