[mono-android] AnimationSet and animation questions

Paul Johnson paul at all-the-johnsons.co.uk
Sat Dec 29 16:45:55 UTC 2012


Hi,

I've decided to go native with my animation and only use what is in 
there. My device is 2.3, so it's the basics.

I've got my view set up with an image view in it and have set up an 
AnimationSet to store what I want in it. From what I've read, this looks 
right.

Problem is, only the last animation is ever displayed.

			AnimationSet animation = new AnimationSet (true);
			animation.Interpolator = new CycleInterpolator (6);
			animation.FillAfter = true;
			
			TranslateAnimation tanim = new TranslateAnimation (0f, 200f, 200f, 0f);
			tanim.Duration = 2000;
			tanim.FillAfter = true;
			animation.AddAnimation (tanim);
			
			RotateAnimation ranim = new RotateAnimation (0f, -359.9f, 180f, 180f);
			ranim.Duration = 600;
			ranim.FillAfter = true;
			ranim.RepeatCount = 5;
			animation.AddAnimation (ranim);
			
			RotateAnimation ranim2 = new RotateAnimation (-359.9f, 0f, 0f, 0f);
			ranim2.Duration = 600;
			ranim2.FillAfter = true;
			ranim2.RepeatCount = 5;
			animation.AddAnimation (ranim2);
			
			foreach (Animation anim in animation.Animations) {
				animate.Animation = anim;
				animate.StartAnimation (anim);
			}

animation.Animations shows there are 3 animations in there.

What I'm also trying to do is to replicate the XML in the Xamarin 
examples (so for example

<set xmlns:android="http://schemas.android.com/apk/res/android"
     android:interpolator="@android:anim/linear_interpolator">
   <rotate
       android:fromDegrees="0"
       android:toDegrees="360"
       android:pivotX="50%"
       android:pivotY="50%"
       android:duration="2000"
       android:startOffset="0"/>
</set>

becomes more like ranim or ranim2. I think I have from/toDegrees correct 
in the ranim constructor, but can't find a way of setting the pivot)

So the question above all, am I doing this the right way. I cannot use 
XML for this as my drawing animations are dependent on data from 
elsewhere (such as an XML file sent to me).

Thanks

Paul
-- 
"Space," it says, "is big. Really big. You just won't believe how 
vastly, hugely, mindbogglingly big it is. I mean, you may think it's a 
long way down the road to the chemist's, but that's just peanuts to 
space, listen..."
Hitch Hikers Guide to the Galaxy, a truly remarkable book!



More information about the Monodroid mailing list