Skip to content

[Android] RenderTransform animation doesn't work well #7812

Closed

Description

@jeromelaban

Repro: AnimationBugDemonstrate-main.zip

Discussed in #7810

Originally posted by limeniye January 12, 2022
Test repository

I have simple animation

UWP.mp4

But in the Android platfrom I have weird result

Android.mp4

Button click

        private void StartAnimationClicked(object sender, RoutedEventArgs e)
        {
            justStoryboard.Pause();
            justStoryboard = new Storyboard();

            SetTestStroyboard(TimeSpan.FromMilliseconds(2_000));

            justStoryboard.Begin();
        }

Animation

        private void SetTestStroyboard(TimeSpan timeSpan)
        {
            var renderTransform = animationBorder.RenderTransform as TranslateTransform;

            var elementVisualRelative = staticBorder.TransformToVisual(this);
            Point staticBorderPostition = elementVisualRelative.TransformPoint(new Point(0, 0));

            #region xAnimation
            DoubleAnimationUsingKeyFrames xAnimation = new DoubleAnimationUsingKeyFrames() { EnableDependentAnimation = true };
            xAnimation.KeyFrames.Add(new LinearDoubleKeyFrame() { Value = staticBorderPostition.X, KeyTime = KeyTime.FromTimeSpan(timeSpan) });
            Storyboard.SetTarget(xAnimation, renderTransform);
            Storyboard.SetTargetProperty(xAnimation, "X");
            #endregion

            #region yAnimation
            DoubleAnimationUsingKeyFrames yAnimation = new DoubleAnimationUsingKeyFrames() { EnableDependentAnimation = true };
            yAnimation.KeyFrames.Add(new LinearDoubleKeyFrame() { Value = staticBorderPostition.Y, KeyTime = KeyTime.FromTimeSpan(timeSpan) });
            Storyboard.SetTarget(yAnimation, renderTransform);
            Storyboard.SetTargetProperty(yAnimation, "Y");
            #endregion

            justStoryboard.Children.Add(xAnimation);
            justStoryboard.Children.Add(yAnimation);
        }
    <Grid>
        <Border x:Name="staticBorder" Background="Red" Height="80" Width="301" HorizontalAlignment="Left" VerticalAlignment="Top">
            <Border.RenderTransform>
                <TranslateTransform X="50" Y="50"/>
            </Border.RenderTransform>
        </Border>

        <Border x:Name="animationBorder" Background="Orange" Height="80" Width="301" HorizontalAlignment="Left" VerticalAlignment="Top">
            <Border.RenderTransform>
                <TranslateTransform X="150" Y="300"/>
            </Border.RenderTransform>
        </Border>

        <Button Content="Start" Click="StartAnimationClicked" Background="Red" Height="50"
                HorizontalAlignment="Stretch" VerticalAlignment="Bottom"/>
    </Grid>
  • UWP
  • WASM
  • WPF Skia
  • Mobile

Activity

  1. added
    kind/bug
    project/animations 🎡
    difficulty/medium 🤔
    on Jan 13, 2022
  2. jeromelaban commented on Jan 13, 2022

    @jeromelaban
    MemberAuthor
  3. dr1rrb commented on Jan 13, 2022

    @dr1rrb
    Member

    The issue is most probably that in your sample your animating 2 properties of the same Transform at once, which is unfortunately not supported yet https://github.com/unoplatform/uno/blob/master/doc/articles/features/working-with-animations.md#general-guidelines

    GitHub
    Build Mobile, Desktop and WebAssembly apps with C# and XAML. Today. Open source and professionally supported. - uno/working-with-animations.md at master · unoplatform/uno
  4. dr1rrb commented on Jan 13, 2022

    @dr1rrb
    Member

    A possible workaround could be to use an AnimationGroup with 2 TranslateTransform

            <Border x:Name="animationBorder" Background="Orange" Height="80" Width="301" HorizontalAlignment="Left" VerticalAlignment="Top">
                <Border.RenderTransform>
                    <TransformGroup>
                        <TranslateTransform x:Name="xTransform" X="150"/>
                        <TranslateTransform x:Name="yTransform" Y="300"/>
                    </TransformGroup>
                </Border.RenderTransform>
            </Border>

    And then in your animation you target directly the xTransform and the yTransform

    I didn't tested it yet though ...

  5. limeniye commented on Jan 13, 2022

    @limeniye
    Contributor

    @dr1rrb I tried to use your recommendations but they didn't give a result.

    Result.after.dr1rrb.recommendations.mp4

    I made these changes to the test repository.

  6. changed the title [-][Android] RenderTransform Animation doesn't work well[/-] [+][Android] `RenderTransform` animation doesn't work well[/+] on Jul 24, 2023
  7. limeniye commented on Nov 16, 2023

    @limeniye
    Contributor

    Is steel doesn't works well? Can we close this issue?

  8. MartinZikmund commented on Jul 18, 2025

    @MartinZikmund
    Member

    Only relevant on native, but works correctly on Skia Android

  9. github-actions commented on May 4, 2026

    @github-actions
    Contributor

    This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs or feature requests.

  10. locked as resolved and limited conversation to collaborators on May 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    difficulty/medium 🤔kind/bugproject/animations 🎡

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions