tag:blogger.com,1999:blog-6843566830671277353.post303007291884925752..comments2023-12-11T22:56:18.291-08:00Comments on Codedependent: DevBytes: Custom Activity AnimationsChet Haasehttp://www.blogger.com/profile/03250991041464602854noreply@blogger.comBlogger1125tag:blogger.com,1999:blog-6843566830671277353.post-50109713164786034702013-06-07T11:42:53.253-07:002013-06-07T11:42:53.253-07:00There is minor issue with the code: the detail ima...There is minor issue with the code: the detail image's scale type is "centerInside" so we should take a transparent paddings (top and bottom or left and right) into account when we scale image. Quick (and dirty) fix for this is to replace onPreDraw content with:<br /><br />mImageView.getViewTreeObserver().removeOnPreDrawListener(this);<br /><br />// Figure out where the thumbnail and full size versions are, relative<br />// to the screen and each other<br />int[] screenLocation = new int[2];<br />mImageView.getLocationOnScreen(screenLocation);<br /> <br />// Scale factors to make the large version the same size as the thumbnail<br />mWidthScale = (float) thumbnailWidth / mImageView.getWidth();<br />mHeightScale = (float) thumbnailHeight / mImageView.getHeight();<br />mWidthScale = mHeightScale = Math.max(mWidthScale, mHeightScale);<br />int leftAndRightPadding = Math.round(mWidthScale * mImageView.getWidth() - thumbnailWidth) / 2;<br />int topAndBottomPadding = Math.round(mHeightScale * mImageView.getHeight() - thumbnailHeight) / 2;<br /><br />mLeftDelta = thumbnailLeft - screenLocation[0] - leftAndRightPadding;<br />mTopDelta = thumbnailTop - screenLocation[1] - topAndBottomPadding;<br /> <br />runEnterAnimation();<br /> <br />return true;<br /><br /><br /><br />P.S. Blogger don't let me use "pre" tag.Alexander Mironovhttps://www.blogger.com/profile/15186826289364109507noreply@blogger.com