Xamarin Forms: ActivityIndicator Size

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.

 

 

 

 

ActivityIndicator Size

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

  1. First solution and this is what I personally prefer, is to set HorizontalOptions or VerticalOptions to “center”.
<ActivityIndicator IsRunning="true" Color="Blue" HorizontalOptions="Center"/>

 2. Scale

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 😉

keyboard_arrow_up