Java getGlobalVisibleRect()到底是什么?
您好,我一直在看zoom a view的开发人员代码,但我似乎不知道这段代码应该做什么:Java getGlobalVisibleRect()到底是什么?,java,android,Java,Android,您好,我一直在看zoom a view的开发人员代码,但我似乎不知道这段代码应该做什么: final ImageView expandedImageView = (ImageView) findViewById( R.id.expanded_image); expandedImageView.setImageResource(imageResId); // Calculate the starting and ending bounds for the zoomed-in i
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's offset as the origin for the
// bounds, since that's 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) 具体来说,我不太确定getGlobalVisibleRect(finalBounds,globalOffset)
应该做什么
2) 另外,startBounds.offset()
究竟要做什么?甚至-globalOffset.x,-globalOffset.y
都意味着什么
哦,谢谢。我以前发现过这个链接,但仍然没有帮助,所以我问了这个问题。我还发现两个stackoverflow帖子试图回答这个问题,但答案非常模糊。@HaniyehKhaksar链接断了