It’s amazing when we use apps that have a quick response time, It’s very nice to see the applications which compromise our waiting time as little as possible. That’s why, as developers, we must put enough effort in ensuring that every application we make has the best performance possible.
Granted, It’s amazing to be able to freely use components and other cool features we may want in our App! But, when using these components, we need to know how the app’s performance will be affected when all the components are together.
In this post we will be learning about some Tips to improve our app’s performance.
Let’s start!
Tip 1⃣: Right assets in right dimensions folder (Xamarin Android)
As we know, in our structure project there are some folders with different dimensions (hdpi, xhdpi, xxhdpi, among others), is recommended to generate the right assets and add it in the correct folder. If you want to know more information on this, I will leave you my article “Comprehending screen densities in Xamarin Android”.
Comprehending screen densities in Xamarin Android
Tip 2⃣: Using right layouts
Use a right layout can be a BIG contribution in our App, we can replace some layouts depending of the uses, for example, in the following scenario, I used a StackLayout to create a design with: Row + Two columns, to do it, I need to create three stacks, but if I use a Grid, I just need to create one!
With Stacklayout
We can do just the same with grid!
Personally, I build all the screens with Grids as a principal layout (In which they possibly apply of course), because this really helps the performance and we can achieve a great result! I recommended you a video from Kym Phillpotts , he teaches us how to create a beautiful screen using a Grid as the main element.. Click here to here to see.
If you want to learn more about GridLayout, I invite you to enter to this post:
Working with GridLayout in Xamarin Forms
Tip : Don’t add a Layout just to add a Padding property
Sometimes we need to add spaces for just a few screen components and that’s why we add a Padding! … But… What happened if the components doesn’t have this property? Maybe, one of the most popular answers maybe: Add the components inside of a layout!! Just something like this:
The best way to use, is as the following line:
To be clear with the concepts, I leave these meanings:
? The
Margin
property represents the distance between an element and its adjacent elements, and is used to control the element’s rendering position, and the rendering position of its neighbors.? The
Padding
property represents the distance between an element and its child elements, and is used to separate the control from its own content.
If you want to know more information about it, you can enter here.
Tip 4⃣: Enabling Xamarin Compiler
You can compile directly in the IL (Intermediate language) with the XAMLC. It bring to us some great benefits such as:
? Compile-time checking of XAML and notify if any error.
? Removes some load and instantiation time for XAML elements.
?Helps reduce the file size of the final assembly by no longer including .xaml files.
How enable it? It’s too easy!
Just add the following line in your .xaml.cs file!
If you want to know more information about it, you can enter here.
Tip 5⃣: Using ImageCell in ListView
One of the most popular way to display the data in a listView is just add an image and show dates such as: Name and description. To do it, we usually add a code like this:
But now, let’s learn another way to do it! The ImageCell bring to us some properties that allow us to display all of these dates with you one control, properties such as: ImageSource, Text and Details. Let’s see the example:
And the result going to be something like this:
If you want to know more information about it, you can enter here.
Thanks for reading ?!!!
Spanish post: https://medium.com/@reyes.leomaris/tips-para-mejorar-el-rendimiento-en-xamarin-forms-4caf78fcc651
References: https://www.youtube.com/watch?time_continue=2107&v=-STAXbsZ-zg
Woah!! Such a piece of the nice information you have shared here, I have read the entire post and I must say that the information is very helpful for me.
Xamarin Development Company texas
You’re welcome! 💚