Reputation: 332
I know ScaleTo can create an animation of a view.
but it will change the height and width,Is there anyway to change it's height by an animation?
Upvotes: 1
Views: 248
Reputation: 18861
You can call the method LayoutTo
.
For example
<StackLayout HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand">
<BoxView x:Name="box" WidthRequest="300" BackgroundColor="Red" HeightRequest="600" />
<Button Clicked="Button_Clicked" Text="Click Me"/>
</StackLayout>
private async void Button_Clicked(object sender, EventArgs e)
{
await box.LayoutTo(new Rectangle(box.Bounds.X, box.Bounds.Y, box.Bounds.Width, 300), 500, Easing.CubicIn);
}
For more details about different animation you can check https://trailheadtechnology.com/xamarin-forms-fancy-animations/
Upvotes: 1