Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.

Commit f880a05

Browse files
authored
Added Antialias support in the Android shapes Paint (#11874) fixes #11858
1 parent 38977a3 commit f880a05

File tree

3 files changed

+64
-1
lines changed

3 files changed

+64
-1
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
using Xamarin.Forms.CustomAttributes;
2+
using Xamarin.Forms.Internals;
3+
using Xamarin.Forms.Shapes;
4+
using System.Collections.Generic;
5+
6+
7+
#if UITEST
8+
using Xamarin.UITest;
9+
using NUnit.Framework;
10+
using Xamarin.Forms.Core.UITests;
11+
#endif
12+
13+
namespace Xamarin.Forms.Controls.Issues
14+
{
15+
[Preserve(AllMembers = true)]
16+
[Issue(IssueTracker.Github, 11858, "Ellipse is not antialised",
17+
PlatformAffected.Android)]
18+
#if UITEST
19+
[NUnit.Framework.Category(UITestCategories.Shape)]
20+
#endif
21+
public class Issue11858 : TestContentPage
22+
{
23+
public Issue11858()
24+
{
25+
#if APP
26+
Device.SetFlags(new List<string> { ExperimentalFlags.ShapesExperimental });
27+
#endif
28+
}
29+
30+
protected override void Init()
31+
{
32+
Title = "Issue 11858";
33+
34+
var layout = new StackLayout();
35+
36+
var instructions = new Label
37+
{
38+
Padding = 12,
39+
BackgroundColor = Color.Black,
40+
TextColor = Color.White,
41+
Text = "If despite scaling the ellipse looks sharp, the test has passed."
42+
};
43+
44+
var ellipse = new Ellipse
45+
{
46+
HorizontalOptions = LayoutOptions.Start,
47+
HeightRequest = 100,
48+
WidthRequest = 100,
49+
Scale = 2,
50+
StrokeThickness = 12,
51+
Stroke = Brush.Red,
52+
Margin = new Thickness(100, 100, 0, 0)
53+
};
54+
55+
layout.Children.Add(instructions);
56+
layout.Children.Add(ellipse);
57+
58+
Content = layout;
59+
}
60+
}
61+
}

Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1487,6 +1487,7 @@
14871487
<Compile Include="$(MSBuildThisFileDirectory)Issue11737.xaml.cs" />
14881488
<Compile Include="$(MSBuildThisFileDirectory)Issue11764.xaml.cs" />
14891489
<Compile Include="$(MSBuildThisFileDirectory)Issue11573.xaml.cs" />
1490+
<Compile Include="$(MSBuildThisFileDirectory)Issue11858.cs" />
14901491
<Compile Include="$(MSBuildThisFileDirectory)Issue9210.cs" />
14911492
<Compile Include="$(MSBuildThisFileDirectory)Issue11865.cs" />
14921493
<Compile Include="$(MSBuildThisFileDirectory)Issue11653.xaml.cs" />

Xamarin.Forms.Platform.Android/Shapes/ShapeRenderer.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,8 @@ public class ShapeView : AView
196196

197197
public ShapeView(Context context) : base(context)
198198
{
199-
_drawable = new ShapeDrawable(null);
199+
_drawable = new ShapeDrawable(null);
200+
_drawable.Paint.AntiAlias = true;
200201

201202
_density = Resources.DisplayMetrics.Density;
202203

0 commit comments

Comments
 (0)