How to draw shapes in Xamarin.Forms

In case you have ever found yourself in the situation of needing to draw a shape in Xamarin.Forms, this is the library you are going to love:

Basically, after importing this library (with nuget) into your project, all you have to do is drawing the form you want to display. You can choose among a variety of shapes, such as Circles, Rectangles and Circle Indicators. The Circle Indicator, in particular, is an interesting control capable of displaying a two stroke width circle where the ticker bit shows the progress out of 100%).

Each shape exposes the following properties:

  • Stroke Color
  • Color (fill)
  • Stroke Width
  • Corner Radius
  • Padding

For instance, if I wanted to draw a circle with a number inside, all I have to do would be using this code:

<ShapeView ShapeType=”CircleIndicator” StrokeColor=”#FF21A0DB” StrokeWidth=”3″
HorizontalOptions=”Center” VerticalOptions=”Center”
WidthRequest=”200″ HeightRequest=”200″/>
<Label x:Name=”BeatLabel” Text=”200″ FontSize=”48″ FontAttributes=”Bold” BackgroundColor=”Transparent” TextColor=”White” VerticalOptions=”Center” HorizontalOptions=”Center” />

And, upon launching your app, the result would be:

ShapeView Circle Screen

As you can see the Circle Shape was correctly rendered, with the number in it! 🙂

On the repo of the project, you can see a comparison between how the shapes are rendered in iOS and Android:

iOS Shapes

iOS Shapes

Android Shapes

Android Shapes

Thanks for reading and…

happy coding! 😀

How to overcome the 2 GB RAM limit on Android Visual Studio 2015 emulators

Good evening everybody!

As a devoted Xamarin dev, as soon as it got available, I installed Visual Studio 2015 Release Candidate on both my work machines, my desktop PC (with 16 GB of RAM) and my Surface Pro 3 (with “just” 4 GB of ram).

And this is where the issue raised: I tried running the new Visual Studio 2015 Android emulator, boosted by Hyper-V, on both PCs, but it relentlessly failed to launch multiple times on my Surface Pro 3, always returning this error:

Android Emulator 2048 MB error

“Visual Studio Emulator for Android: The emulator is unable to verify that the virtual machine is running: Not enough memory is available in the system to start an emulator that uses 2048 MB of startup RAM. Please close other applications and try to launch the emulator again. If closing other applications doesn’t help, please follow the instructions on this KB article:;

And that’s what I did! I slavishly followed every single step that was suggested by that Microsoft article, and this would have theoretically led me to have a running Hyper-V Android emulator on my PC, but upon several restarts and attempts, nothing changed.

That’s where I opened the Hyper-V Manager and manually modified the settings of the Emulator “VS Emulator 5-inch KitKat (4.4) XXHDPI Phone.guido”, in order to make it need 1024 MB instead than 2048 MB. It may have worked out at first, but Visual Studio thought: “Why did he change the required RAM to 1024 MB? Hey! Let’s revert it to 2048 MB, so his poor PC won’t be capable of handling it!” (yeah, I have around 1.5 GB of free RAM, sadly, with just Visual Studio 2015 running on my SP3).

In complete despair, I started wandering in the Visual Studio installations folders on my PC, to check where the heck it was forcing the starting RAM of the emulator to be exactly 2048 MB. I encountered some files that didn’t help me at all, but at last I found the right ones, modified them and, upon trying again, my Hyper-V Android emulator was running great on my Surface Pro 3! 😀

The configuration (.cfg) files you have to modify are located here:


Just head to this URL and you will find the four little bastards:


Now you will just have to open each one of them and change this line content, replacing the “2048” value with “1024”:

FROM: device.vm.ram.size=2048
TO: device.vm.ram.size=1024

While I didn’t try if the emulators were launching with lower RAM values, I suppose that it’s possible reducing the RAM size until 512 MB without incurring in major issues (and unless you are debugging a game or something as heavy). All I can say is that with 1024 MB the Hyper-V Android emulators run just as fine as they run with 2048 MB on my desktop PC.

I am leaving here a link to download a .zip file to make you able to download the four files, already patched and such:

Well, this is what worked for me! 🙂 Feel free to post below here for more support, should you still have that infamous screen show up after following my guide!

Happy coding! 🙂

Why should I make my next mobile app in Xamarin? #Part5: You are using C#!

In this brief post, the 5th of the series, we will analyze why it’s relevant that Xamarin is build around C#! 🙂

Well, starting from basics, one of the main advantages of C# are the support of LINQ, which allows you to execute queries and select data from arrays and databases like SQLite. An example of LINQ:


Moreover, in C# you can easily manage Events and Delegates:


And you can work with IntelliSense and Lambda expressions!
Also, C# natively supports JSON through the Json.NET library. Json.NET offers simple conversions to and from JSON strings and .NET objects, with SerializeObject and DeserializeObject methods.
Here is an example of creating a class with a method to get names:

ObjCClass C#Class

In C#, one line with LINQ is used to execute the whole command. Also, the C# class takes advantage of C# features and set properties easily.
Last but not least, the Async/Await constructs will allow you to set up a multithreading environment with the lowest effort possible. Below here a comparison between the Async/Await and the same code written in Objective-C!
ObjCAsync C#Async

See you on the next post! 😀
Happy coding! 🙂

Why should I make my next mobile app in Xamarin? #Part4: Xamarin VS Cordova/Titanium/etc

Good evening everybody, at last I found some time to write the fourth post of the series! In this short post we will analyse why you should choose Xamarin over Cordova, Titanium or any other javascript/web-based framework.

Until Xamarin was launched, the approach used while programming in Cordova, Titanium and other similar frameworks was similar to this:


Let’s now get deep into the problems this kind of programming was causing:

  • Browser fragmentation, was often causing developers issues because of deprecated components on updated browsers and unsupported components on old, not updatable, browsers.
  • The app was designed only for one platform, and often the design of an Android app has to be radically different than the design of the very same app running on Windows Phone or iOS.

This often caused unhappy users, which can’t use an app that was natively built for their phone and unhappy developers which received lots of complaints from their unhappy users. Unhappy developers means abandones apps, which will no longer receive updates. Also, the said frameworks have strong implementation limitations, and often can’t access all of the APIs on the target device.

And this is why Xamarin became important, thanks to its ability to easily cope with all these problems. The image down here describes how exactly Xamarin works:


The UI is built natively per platform, leveraging C#. The approach is having one shared app logic code base for all of the following platforms: iOS, Android, Mac, Windows phone, Windows Store, Windows. And, most importantly, Xamarin is built around C#, and if you want to know what’s so awesome about C#, you will have to wait until the fifth post of the series! 😀

See you soon!

Why should I make my next mobile app in Xamarin? #Part1: Xamarin Performance

In this series of articles we are going to deeply analyze why it should be convenient for you (or not) developing a Mobile App using Xamarin.

One of the main doubts that is often raised by anyone I speak about Xamarin with is about the app performance.

I found an interesting in-depth review which analyses the differences between Xamarin’s Android and Java Android performance, as well as the differences between iOS native code and Xamarin’s iOS.

This is the test which involves Java (Android):


And this is the test that puts in comparison iOS native code and Xamarin’s C#:


In both case Xamarin is able to almost match the performance granted by the native platform itself, and frankly that’s quite awesome considering that Xamarin is still a young platform and has a lot of space to grow in the near future. In a few cases Xamarin even outperformed the native platform.

You can find the detailed performance comparison here:

And the github repo with the code used during the test here:

See you on the next post, and happy coding! 🙂

Xamarin.Forms updated to 1.3.3 :)

This evening Xamarin Forms, the best tool offered by Xamarin to build native UIs for iOS, Android and Windows Phone from a single, shared C# codebase, picked up an update which bumps its version number up to the 1.3.3 version. You can find a detailed changelog at this link:

or just below here 🙂

Release Notes

## Enhancements ##

– Deeply nested Grid performance enhanced

## Bug Fixes ##

– [Bug 21606]( – Page Title not updating when set in OnAppearing() Method the second time page is displayed. (iOS)
– [Bug 20798]( – ListView TextCell.DetailProperty only wraps on Android
– [Bug 24777]( – jobject must not be IntPtr.Zero exception when replacing Content of a Page
– [Bug 26214]( – On Android, InputTransparent=true does not work with ScrollView
– [Bug 22673]( – Initially hidden BoxView when made visible does not render (but does take up space in the UI)
– [Bug 25703]( – Webview waits to load the content until webviews on previous pages are loaded
– [Bug 26139]( – Navigation.RemovePage() still shows the back button on Android
– [Bug 26304]( – System.ArgumentNullException thrown when moving items in an ObservableCollection that is observed by a ListView
– [Bug 26064]( – ListView, ImageCell and disabled source cache and same image url leads to degraded performance
– [Bug 26121]( – Android ListView.ScrollTo doesn’t work when ListView inside TabbedPage
– [Bug 26501]( – Context Actions cause views to be hidden on iOS after re-use
– [Bug 23585]( – [Android] ListView not updated when ObservableCollection is modified

## Other Fixes ##

– [Core] CarouselPage now has more informative error when used without Children
– [Android] BoldItalic text now works as expected
– [Android] HeaderCells no longer tapable in TableView
– [Android] Fix NullReferenceException when re-using ListView on second page
– [iOS] SearchBar cancel button hides if there is nothing to clear
– [iOS] EntryCell Completed event fires twice
– [iOS] Fix potential crash with Editor inside of a ScrollView
– [iOS] Fix potential crash when ScrollView is inside of ViewCell
– [iOS] Fix issue where ContextActions could end up out of order
– [WP] Keyboard action for search does not match other platforms
– [Xaml] Text as content property now properly trims whitespace
– [Xaml] Duplicate x:Name’s throw a more informative error now
– [Xaml] Better error on Type mismatch for

Update it asap and tell us if anything improved in your everyday Forms coding! 🙂