Photo sizes for the two ImageViews


Being a Photographer and game modder, I have edited photos and other images in Photoshop, resizing them for various venues. I don’t understand the image processing here.

I traced the code to the return statement in PhotoUtils.getScaledDrawable(…). At that point (for a Galaxy Nexus, 4.7", 720x1280):

options.outHeight = 480
options.outWidth = 640

Meanwhile, we set the ImageView for the thumbnail to:


How does 480 compare to 80dp? Are they both pixel measurements?

However, the ImageView is not used for determining the image size. The activity is. The activity for CrimeFragment and ImageFragment is CrimePagerActivity. So, the call will return the same result for both the thumbnail and fullscreen images.

This brings two questions:

  1. If we are going to use the screen size for both images, why do we need two calls? Can’t the same image used for the thumbnail be used for the fuilscreen one?

  2. At the time the picture is taken, why can’t we create two image files then, a small one for the thumbnail and a larger one for the fullscreen display? Do we need the full image as captured by the camera (which could be an 8mb or larger file)? Wouldn’t it be a lot more efficient to save only the images we need for the two views, doing the calculations once at capture time instead of every time the image is displayed? Or are we going to save the full one for possible printing? The app data is being saved to internal storage, not the external SSD. Saving the full size image is a waste of space.

Another question I have is why we don’t use the UUID of the Crime for the filename, instead of generating a new one? Then the app can check for the existence of images without needing to save the filename separately.

Thank you!



  1. Can’t you determine the size of the ImageView in onResume()?
  2. If we are just going to save one jpg file, shouldn’t we at least resize the original before saving it to file? What happens in the ViewPager as it keeps 3 Crimes loaded at once for paging? Do we not care about the memory usage and need to scale the image every time we need to re-init the ImageView?



Answers to your questions in the first post:

1- Yes, you can use the same bitmap for the fullscreen and for the thumbnail.

2- Yep, you can. You can use our method to scale down the bitmap to a smaller size, and then use the Bitmap.compress method to save out a compressed version of the image.

3- Yep, you can use the UUID of the crime if you like. I prefer having the ids separate, as the photo is a distinct entity from the crime.

And the second post:

1- Nope. You have to wait until a layout pass. Check out View.getViewTreeObserver() - this allows you to listen for the next layout pass. Once that happens, getWidth(), getHeight(), getX(), and getY() will all return valid values on your ImageView.

2- Sure, if it’s appropriate for your app.

2a- Correct - three images are loaded. For a more complicated app you would need to apply the more advanced techniques you’re describing. Picasso ( - I’ve got a blog post on it here: is a library that intends to solve this (and other image issues) in a nice, easy way. It’s not perfect, yet, but it’s getting there pretty rapidly.