Using sdk 10,(Android Q) seems like breaking changes in Animation class.

i have used animation end event handler in my application. after updated target type as android q, events not available in animation class. and i found iAnimationListener interface. but not have enough information about this change.

And also need to know, are we need to use condition compilation for this changes? like lower version use event handler and higher version use listener?

Animation MyAnimation = new Animation();
...
MyAnimation.AnimationEnd += (s,e) => {
if (ChildCount > 1) {
RemoveViewAt(0);
}
}

Best Answer

Answers

  • JarvanJarvan Member, Xamarin Team Xamurai

    i have used animation ... events not available in animation class

    Do you mean using Animation in Xamarin.Android.Support.Design 28.03? I tested a basic demo and it works well. To use Animaiton class, add the using Android.Views.Animations; statement.

    Animation animation = AnimationUtils.LoadAnimation(this, Resource.Animation.abc_fade_in);
    animation.AnimationEnd += (s, e) =>
    {
        //
    };
    

    Check the sample code about Animation.
    https://docs.microsoft.com/en-us/samples/xamarin/monodroid-samples/animationdemo/

  • @Jarvan i am using translation animation which inherit from animation.

    ` TranslateAnimation animation;
     animation = new TranslateAnimation(from, to, 0, 0);
    animation.AnimationEnd +=AnimationEnd;` // throws compiler error. 
    
  • @Jarvan i have tried the same with

    faced above error while build with target type android Q (10).

  • i able to use IAnimationListener but worried about, my application did not deploy in lower version.

    How to use condition compilation between sdk version?

  • JarvanJarvan Member, Xamarin Team Xamurai

    How to use condition compilation between sdk version?

    Try the following code.

    if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.N)
    //if ((int) Android.OS.Build.VERSION.SdkInt >= 27)
    {
        //
    }
    else
    {
        //
    }
    
  • saravananMadheswaransaravananMadheswaran Member ✭✭
    Accepted Answer

    i have used object animator instead of this approach.

Sign In or Register to comment.