We all will need at some point to show an activity indicator when our app has to perform lenghty data processing operations or when we have to wait for our app to load content. In Xamarin Forms we can use in a xaml file this property called ActivityIndicator.
<ActivityIndicator IsRunning="true" Color="Blue"/>
Below is the result of the above code.
As you can see, on Android the size it’s way too large. The default scale is 1 on both platforms. How to reduce the ActivityIndicator size? Well, we have 2 solutions:
1. HorizontalOptions or VerticalOptions
- First solution and this is what I personally prefer, is to set HorizontalOptions or VerticalOptions to “center”.
<ActivityIndicator IsRunning="true" Color="Blue" HorizontalOptions="Center"/>
The second solution is to add Scale property.
<ActivityIndicator IsRunning="true" Color="Blue" Scale="0.2"/>
As you can see, on iOS the size is so small now, that is barely visible. So if you need to use the Scale you will have to set it separately on iOS and Android.
<ActivityIndicator IsRunning="true" Color="Blue"> <ActivityIndicator.Scale> <OnPlatform x:TypeArguments="x:Double" iOS="1" Android="0.2" /> </ActivityIndicator.Scale> </ActivityIndicator>
And this is it. You can reduce now the size as you please 😉
Search In Blog
Want to donate?
Recent Posts: My Android Solutions
If you ever wondered how to read and parse a simple JSON file stored in the assets directory of your Android project, here is a way to do it.
In this tutorial I will create a simple Sectioned RecyclerView that will show 2 sections and a few items in each section and how to move an item from one section to another. Note: For RecyclerView I used AndroidX imports and not android.support.v7.widget.RecyclerView! Setup We need to import the recycler view from AndroidX. The build.gradle…
Recently, I had to add a perfect square CardView and I wanted to achieve this without hardcoding its width and height. I happily discovered the power of ConstraintLayout and this is how I managed to create a perfect square which should work on every dimension. In my project I created a RecyclerView with 2 columns,…