I'm trying to a make a horizontal fill animation from the center to the edges of a other view.
First i have centralized the view that will do the expand animation on the center of the main view and then animate with a ScaleXTo to the main view width:
XAML code:
<StackLayout Padding="16" Spacing="10">
<Grid
Margin="0,0,0,16">
<BoxView
x:Name="firstView"
BackgroundColor="Blue"
HorizontalOptions="Start"
HeightRequest="30"
WidthRequest="180" />
<BoxView
x:Name="secondView"
BackgroundColor="Black"
HeightRequest="10"
Scale="1"
HorizontalOptions="StartAndExpand"
VerticalOptions="Center"
WidthRequest="1" />
</Grid>
<Button
Clicked="Button_OnClicked"
Text="Animate!" />
</StackLayout>
The code behind:
private void Button_OnClicked(object sender, EventArgs e) {
secondView.TranslationX = firstView.Bounds.Center.X;
secondView.ScaleXTo(firstView.Width);
}
When executed, the animated view becomes larger than the main view, as can be seen on the print below