public async void OnGlobalLayout() { productImage.ViewTreeObserver.RemoveGlobalOnLayoutListener(this); const int DeltaX = 100; var img1 = Images.FromUrl(Product.ImageForSize(images [0], Images.ScreenWidth)); var img2 = Images.FromUrl(Product.ImageForSize(images [1], Images.ScreenWidth)); productDrawable = new KenBurnsDrawable(Color.DarkBlue); productDrawable.FirstBitmap = await img1; productDrawable.SecondBitmap = await img2; productImage.SetImageDrawable(productDrawable); currentIndex++; var evaluator = new MatrixEvaluator(); var finalMatrix = new Matrix(); finalMatrix.SetTranslate(-DeltaX, -(float)productDrawable.FirstBitmap.Height / 1.3f + (float)productImage.Height); finalMatrix.PostScale(1.27f, 1.27f); kenBurnsMovement = ValueAnimator.OfObject(evaluator, new Matrix(), finalMatrix); kenBurnsMovement.Update += (sender, e) => productDrawable.SetMatrix((Matrix)e.Animation.AnimatedValue); kenBurnsMovement.SetDuration(14000); kenBurnsMovement.RepeatMode = ValueAnimatorRepeatMode.Reverse; kenBurnsMovement.RepeatCount = ValueAnimator.Infinite; kenBurnsMovement.Start(); kenBurnsAlpha = ObjectAnimator.OfInt(productDrawable, "alpha", 0, 0, 0, 255, 255, 255); kenBurnsAlpha.SetDuration(kenBurnsMovement.Duration); kenBurnsAlpha.RepeatMode = ValueAnimatorRepeatMode.Reverse; kenBurnsAlpha.RepeatCount = ValueAnimator.Infinite; kenBurnsAlpha.AnimationRepeat += (sender, e) => NextImage(); kenBurnsAlpha.Start(); }
public async void OnGlobalLayout () { productImage.ViewTreeObserver.RemoveGlobalOnLayoutListener (this); const int DeltaX = 100; var img1 = Images.FromUrl (Product.ImageForSize (images [0], Images.ScreenWidth)); var img2 = Images.FromUrl (Product.ImageForSize (images [1], Images.ScreenWidth)); productDrawable = new KenBurnsDrawable (Color.DarkBlue); productDrawable.FirstBitmap = await img1; productDrawable.SecondBitmap = await img2; productImage.SetImageDrawable (productDrawable); currentIndex++; var evaluator = new MatrixEvaluator (); var finalMatrix = new Matrix (); finalMatrix.SetTranslate (-DeltaX, -(float)productDrawable.FirstBitmap.Height / 1.3f + (float)productImage.Height); finalMatrix.PostScale (1.27f, 1.27f); kenBurnsMovement = ValueAnimator.OfObject (evaluator, new Matrix (), finalMatrix); kenBurnsMovement.Update += (sender, e) => productDrawable.SetMatrix ((Matrix)e.Animation.AnimatedValue); kenBurnsMovement.SetDuration (14000); kenBurnsMovement.RepeatMode = ValueAnimatorRepeatMode.Reverse; kenBurnsMovement.RepeatCount = ValueAnimator.Infinite; kenBurnsMovement.Start (); kenBurnsAlpha = ObjectAnimator.OfInt (productDrawable, "alpha", 0, 0, 0, 255, 255, 255); kenBurnsAlpha.SetDuration (kenBurnsMovement.Duration); kenBurnsAlpha.RepeatMode = ValueAnimatorRepeatMode.Reverse; kenBurnsAlpha.RepeatCount = ValueAnimator.Infinite; kenBurnsAlpha.AnimationRepeat += (sender, e) => NextImage (); kenBurnsAlpha.Start (); }