Hi, I watched the developer code to enlarge the image, and I cannot figure out what this code should do:
final ImageView expandedImageView = (ImageView) findViewById( R.id.expanded_image); expandedImageView.setImageResource(imageResId); // Calculate the starting and ending bounds for the zoomed-in image. // This step involves lots of math. Yay, math. final Rect startBounds = new Rect(); final Rect finalBounds = new Rect(); final Point globalOffset = new Point(); // The start bounds are the global visible rectangle of the thumbnail, // and the final bounds are the global visible rectangle of the container // view. Also set the container view offset as the origin for the // bounds, since that the origin for the positioning animation // properties (X, Y). thumbView.getGlobalVisibleRect(startBounds); findViewById(R.id.container) .getGlobalVisibleRect(finalBounds, globalOffset); startBounds.offset(-globalOffset.x, -globalOffset.y); finalBounds.offset(-globalOffset.x, -globalOffset.y);
1) In particular, I'm not sure what to do getGlobalVisibleRect(finalBounds,globalOffset)
?
2) Besides, what exactly does startBounds.offset()
and what does -globalOffset.x,-globalOffset.y
even -globalOffset.x,-globalOffset.y
?
source share