/// <summary> /// The event handler for the thumbnails. Called when they are clicked, it display /// the full sized image, animating the transition from thumbnail to full sized image. /// </summary> /// <param name="sender"></param> /// <param name="eventArgs"></param> private void ZoomImageFromThumb(object sender, EventArgs eventArgs) { View thumbView = (View)sender; ImageView expandedImageView = GetExpandedImageView(thumbView); if (_currentAnimator != null) { _currentAnimator.Cancel(); } Rect startBounds = new Rect(); Rect finalBounds = new Rect(); Point globalOffset = new Point(); // The start bounds are the global visible rectangle of the thumbnail thumbView.GetGlobalVisibleRect(startBounds); // The final bounds are the global visible rectangle of the container view. Also // set the container view's offset as the origin for the bounds, since that's // the origin for the positioning animation properties (X, Y). FindViewById(Resource.Id.container).GetGlobalVisibleRect(finalBounds, globalOffset); startBounds.Offset(-globalOffset.X, -globalOffset.Y); finalBounds.Offset(-globalOffset.X, -globalOffset.Y); float startScale = CalculateStartScale(startBounds, finalBounds); // Construct and run the parallel animation of the four translation and scale properties // (X, Y, SCALE_X, and SCALE_Y). AnimatorSet expandSet = BuildExpandingAnimatorSet(expandedImageView, startBounds, finalBounds, startScale); expandSet.Start(); _currentAnimator = expandSet; // Upon clicking the zoomed image, it should zoom back down to the original bounds // and show the thumbnail instead of the expanded image. expandedImageView.Click += (o, args) =>{ if (_currentAnimator != null) { _currentAnimator.Cancel(); } AnimatorSet shrinkSet = BuildShrinkingAnimatorSet(expandedImageView, thumbView, startBounds, startScale); shrinkSet.Start(); _currentAnimator = shrinkSet; }; }