Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Skia Sharp - problem on Android

$
0
0

Hi everybody,
i am developing a radial menu with skia sharp on xamarin forms

here is the function that draws the control

    SKCanvasView ElementBuilder()
    {
        var element = new SKCanvasView();
        element.PaintSurface += (sender, e) =>
        {
            diameter = (float)(Width / 1.5);
            var canvas = e.Surface.Canvas;
            canvas.Clear(SKColors.Transparent);
            canvas.Translate((float)(Width), (float)(Height));
            var angles = new float[5] { 234, 306, 18, 90, 162 };
            using (var path = new SKPath())
            {
                foreach (var item in angles)
                {
                    path.ArcTo(new SKRect(-diameter, -diameter, diameter, diameter), item, 72, true);
                }
                canvas.DrawPath(path, elementPaint);
            }
            using (var path = new SKPath())
            {
                foreach (var item in angles)
                {
                    path.LineTo(DegreesToXY(item, (-diameter - (strokeWidth / 2))));
                    path.MoveTo(0, 0);
                    path.LineTo(DegreesToXY(item + 72, (-diameter - (strokeWidth / 2))));
                    path.MoveTo(0, 0);
                }
                canvas.DrawPath(path, backgroundPaint);
            }

        };
        return element;
    }

Works perfectly on every iOS device I have tested and on my personal device which i used during development (Sony xperia z3 compact)
On every other Android device, with any version of the os the sizing of the view is different

I upload here 3 screenshot (IPhone 7 simulator, Xperia z3 compact, Nexus 5)



Every Android device renders the same (the third image), except the sony
How to give the correct size to the view?

Thank in advance


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>