Customization in Xamarin Shimmer (SfShimmer)
29 Sep 20239 minutes to read
The Shimmer control supports options to customize the wave color, shimmer color, wave direction, wave animation duration, and more. This section explains how to customize the shimmer control.
WaveDirection
The WaveDirection
property of SfShimmer
is used to change the direction of shimmer wave. The following different wave directions are available in SfShimmer
:
Default
LeftToRight
TopToBottom
RightToLeft
BottomToTop
<shimmer:SfShimmer x:Name="shimmer" VerticalOptions="FillAndExpand" WaveDirection="LeftToRight">
<shimmer:SfShimmer.Content>
<StackLayout>
<Label Text="Content is loaded!"/>
</StackLayout>
</shimmer:SfShimmer.Content>
</shimmer:SfShimmer>
shimmer = new SfShimmer()
{
WaveDirection = WaveDirection.LeftToRight,
VerticalOptions = LayoutOptions.FillAndExpand,
Content = new Label
{
Text = "Content is loaded!"
}
};
this.Content = shimmer;
Color
The Color
property of SfShimmer
is used to customize the color of shimmer.
<shimmer:SfShimmer x:Name="shimmer" VerticalOptions="FillAndExpand" Color="#F4E2EE">
<shimmer:SfShimmer.Content>
<StackLayout>
<Label Text="Content is loaded!"/>
</StackLayout>
</shimmer:SfShimmer.Content>
</shimmer:SfShimmer>
shimmer = new SfShimmer()
{
Color = Color.FromHex("#F4E2EE"),
VerticalOptions = LayoutOptions.FillAndExpand,
Content = new Label
{
Text = "Content is loaded!"
}
};
this.Content = shimmer;
WaveColor
The WaveColor
property of SfShimmer
is used to customize the color of wave.
<shimmer:SfShimmer x:Name="shimmer" VerticalOptions="FillAndExpand" WaveColor="#B8D4F2">
<shimmer:SfShimmer.Content>
<StackLayout>
<Label Text="Content is loaded!"/>
</StackLayout>
</shimmer:SfShimmer.Content>
</shimmer:SfShimmer>
shimmer = new SfShimmer()
{
WaveColor = Color.FromHex("#B8D4F2"),
VerticalOptions = LayoutOptions.FillAndExpand,
Content = new Label
{
Text = "Content is loaded!"
}
};
this.Content = shimmer;
WaveWidth
The WaveWidth
property of SfShimmer
is used to customize the width of wave.
<shimmer:SfShimmer x:Name="shimmer" VerticalOptions="FillAndExpand" WaveColor="#B8D4F2" WaveWidth ="100">
<shimmer:SfShimmer.Content>
<StackLayout>
<Label Text="Content is loaded!"/>
</StackLayout>
</shimmer:SfShimmer.Content>
</shimmer:SfShimmer>
shimmer = new SfShimmer()
{
WaveWidth = 100,
WaveColor = Color.FromHex("#B8D4F2"),
VerticalOptions = LayoutOptions.FillAndExpand,
Content = new Label
{
Text = "Content is loaded!"
}
};
this.Content = shimmer;
AnimationDuration
You can control the duration of wave animation using the AnimationDuration
property of SfShimmer
. The default value of AnimationDuration
is 1000 ms.
<shimmer:SfShimmer x:Name="shimmer" VerticalOptions="FillAndExpand" AnimationDuration ="2000">
<shimmer:SfShimmer.Content>
<StackLayout>
<Label Text="Content is loaded!"/>
</StackLayout>
</shimmer:SfShimmer.Content>
</shimmer:SfShimmer>
shimmer = new SfShimmer()
{
AnimationDuration = 2000,
VerticalOptions = LayoutOptions.FillAndExpand,
Content = new Label
{
Text = "Content is loaded!"
}
};
this.Content = shimmer;