Skixam: SkiaSharp as a Platform for Xamarin.Forms (Proof-of-concept)

With the recent conversation around Flutter, I decided to test out how things would work, if Xamarin.Forms ran on SkiaSharp, rather than using the platform APIs. I managed to create a proof of concept, of a Xamarin.Forms ContentPage, with one Label, showing on SkiaSharp. At the time of this post, this is all it can do.

GitHub Repo: Skixam.

App Setup

As you will see in the Sample app, it is very easy to get started. All you need to do is replace what you inherit from, in your MainActivity or AppDelegate. Everything else in your Xamarin.Forms app remains the same.

public partial class AppDelegate : SkixamApplicationDelegate
public class MainActivity : SkixamAppCompatActivity

In each of these activities or delegates, we create a View or UIView, and place an SKSurface and Canvas down on it. We then search for the elements, and use the renderer to draw on the canvas.

Single Renderer

With the Skia approach, there is only one renderer needed, as Skia is taking care of the API calls to each platform. This means whatever platform SkiaSharp supports, this would be able to run on. It could result with quicker support for new platforms, and worrying less about native platform changes made, with each release, along with a more consistent UI. As one thing I am now starting to notice in commercial Xamarin.Forms projects, is they are not really sticking to the native look and feel anymore, and want it almost identical across platforms.

Benefits

  • Only 1 default renderer. No need for platform specific renderers.
  • You can still override a renderer, for platform specific changes if needed.
  • Potentially faster viewing and scrolling.
  • Quicker support for new platforms.

Summary

This was only a proof of concept, and it worked rather well. I would need to spend more time to add in Touch, and Layout. I believe once those are added, making renderers for other elements would come quite quickly and easily. It’s kind of cool that there is the potential to run an existing Xamarin.Forms application on SkiaSharp instead of the platform, with a single line change in your platform specific Xamarin project. I might advance further on this soon.


XAMARIN.FORMS MONTHLY NEWSLETTER

JOIN 1,200+ SUBSCRIBERS

  1. Don't miss out on updates
  2. The latest info from this site, Xamarin and the community
  3. Unsubscribe at any time*

* We use MailChimp, with double opt-in, and instant unsubscribe

Microsoft MVP | Xamarin MVP | Xamarin Certified Developer |
Exrin MVVM Framework | Xamarin Forms Developer | Melbourne, Australia

Related Posts

4 Comments

    1. Adam Pedley

      Thanks Alessandro 🙂

      The conversation about Flutter (https://flutter.io/), I was referring to just general discussion that has been happening since Google announced it, and Tim Sneath moving from MS to Google to work on it, which got it a bit of attention.