Xamarin has a long story of problematic releases where new features comes along with numerous bugs.
For this reason is possible that you are still using an old version of Xamarin.Forms.
But today you will see why you should really upgrade to Xamarin.Forms 2.5
Sometimes to create the UI we want, we need to add several layouts that are not visible but are needed as container for other components.
As you can imagine, all these layouts come with a cost and you can see it especially on older Android devices.
Layout compression helps us to solve this problem reducing the number of views to render.
Consider this basic example:
We have a StackLayout that contains two buttons, the only reason to have this layout is to add the two buttons at the same height.
Even if we don’t see the layout, having it in our Page has a cost.
With the Layout Compression we can keep the StackLayout and remove its cost.
To enable the compression of the StackLayout we need to add the code
so the previous example will be:
Easy. Isn’t it?
You can enable the Layout compression on: StackLayout, AbsoluteLayout, Grid, RelativeLayout.
Because the compression removes the renderer for the layout, candidates for the compression are layouts that don’t have:
- Background color
Layout Compression is available on iOS and Android.
Ok this is not entirely a new feature (they arrived on Xamarin.Forms 2.4) but it’s definitely a feature you shouldn’t miss.
We love Xamarin but we also know that sometimes, especially on Android the performances are not really amazing.
Fast Renderers for Android will improve performances on your Xamarin.Forms applications.
As this is still an experimental feature, to enable them you need to add this line
MainActivity class before calling
I’ve personally tested Layout compression and Fast Renderers and I can confirm that there is a performance improvement expecially on older Android devices so I really suggest you to use these features in your projects.
I have to tell you, I’m not particularly inclined to mix things so I prefer to keep separated Xamarin.Forms and native Xamarin projects.
BUT…I can honestly see cases where you already have existing Xamarin.Forms pages and you want to use in other Xamarin iOS, Android or UWP projects.
Thanks to the Forms Embedding now you can do it.
Improved macOS Desktop Support
In case you want to add macOS desktop support in your Xamarin.Forms apps 🙂