developer9969
developer9969

Reputation: 5236

Scaling an image in Xamarin form

I have been trying to make my image and text to scale when the forms appears, but i still cannot get the effect.

What Have I done.

  1. I have given an "x:Name" to the svgcachedImage - labelTitle and LabelDescription
  2. In the constructor of my page I have used the scale method to create the effect
  3. Didnt work

What I am trying to create

If you go to this link https://www.syncfusion.com/blogs/post/create-a-wizard-view-in-xamarin-forms.aspx at the bottom there is gif that shows the scaling.(I have not got syncfusion)

Any suggestion on how to scale an image when loading a page?

Upvotes: 0

Views: 184

Answers (2)

user666
user666

Reputation: 332

you can use the animation

Task.WhenAll(
await image.ScaleTo(1.5,5000);
await text.SacleTo(1.5,5000);
)

As you know you can animation the obj at the same time. not one after one so you can use Task.WhenAll();

then you can use the code in

protected override async void OnAppearing(){}

Upvotes: 0

Wendy Zang - MSFT
Wendy Zang - MSFT

Reputation: 10978

The scarling is the simple animations in Xamarin.Forms.

You could use the ScaleTo method to animate the Scale property of an Image or Label.

  await svgcachedImage.ScaleTo(2, 2000);
  await svgcachedLabel.ScaleTo(2, 2000);    

This code animates the Image instance by scaling up to twice its size over 2 seconds (2000 milliseconds).

Or you could use the RelScaleTo method to do the relative scaling of an Image.

await svgcachedImage.RelScaleTo(2, 2000);

For more details, you could check the MS docs: https://learn.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/animation/simple#canceling-animations

You could downlaod the source file from the NuGet for reference. https://learn.microsoft.com/en-us/samples/xamarin/xamarin-forms-samples/userinterface-animation-basic/

Upvotes: 1

Related Questions