Contents
- Enable animation
- Animation duration
Having trouble getting help?
Contact Support
Contact Support
Animation in .NET MAUI Badge View (SfBadgeView)
Enable animation
You can enable or disable the animation of the badge text using Scale or None enum values of the BadgeAnimation property. You can see the animation when you change the badge text.
<badge:SfBadgeView HorizontalOptions="Center" WidthRequest="70" HeightRequest="70" BadgeText="6"
VerticalOptions="Center">
<badge:SfBadgeView.Content>
<Image Source="BadgeFacebook.png" HeightRequest="70" WidthRequest="70" />
</badge:SfBadgeView.Content>
<badge:SfBadgeView.BadgeSettings>
<badge:BadgeSettings Type="Error" Animation="Scale" Offset="-12,6" Position="TopRight" />
</badge:SfBadgeView.BadgeSettings>
</badge:SfBadgeView>
SfBadgeView sfBadgeView = new SfBadgeView();
sfBadgeView.HeightRequest = 70;
sfBadgeView.WidthRequest = 70;
sfBadgeView.HorizontalOptions = LayoutOptions.Center;
sfBadgeView.VerticalOptions = LayoutOptions.Center;
sfBadgeView.BadgeText = "6";
Image image = new Image();
image.Source = "BadgeFacebook.png";
image.HeightRequest = 70;
image.WidthRequest = 70;
sfBadgeView.Content = image;
BadgeSettings badgeSetting = new BadgeSettings();
badgeSetting.Type = BadgeType.Error;
badgeSetting.Animation = BadgeAnimation.Scale;
badgeSetting.Offset = new Point(-12, 6);
badgeSetting.Position = BadgePosition.TopRight;
sfBadgeView.BadgeSettings = badgeSetting;
Content = sfBadgeView;
Animation duration
The AnimationDuration property of the Badge Settings in the Badge View can be used to set the animation speed based on the given value. Setting a smaller duration value accelerates the animation speed. Its default value is 250.
<badge:SfBadgeView BadgeText="6">
<badge:SfBadgeView.Content>
<Image Source="BadgeFacebook.png" HeightRequest="70" WidthRequest="70" />
</badge:SfBadgeView.Content>
<badge:SfBadgeView.BadgeSettings>
<badge:BadgeSettings AnimationDuration="600" Animation="Scale"/>
</badge:SfBadgeView.BadgeSettings>
</badge:SfBadgeView>
SfBadgeView sfBadgeView = new SfBadgeView();
sfBadgeView.BadgeText = "6";
Image image = new Image();
image.Source = "BadgeFacebook.png";
image.HeightRequest = 70;
image.WidthRequest = 70;
sfBadgeView.Content = image;
BadgeSettings badgeSetting = new BadgeSettings();
badgeSetting.Animation = BadgeAnimation.Scale;
badgeSetting.AnimationDuration = 600;
sfBadgeView.BadgeSettings = badgeSetting;
Content = sfBadgeView;