/** * Given the width and height of a given image, this movie scales them, if necessary, to conform * to a 27:40 (w x h) aspect ratio. * * @param imageWidth to be scaled if necessary * @param imageHeight to be scaled if necessary */ @Override protected void onMeasure(final int imageWidth, final int imageHeight) { final Drawable d = getDrawable(); if (d != null) { final int width = getSize(imageWidth); final int height = (int) ceil(width * ASPECT_RATIO); setMeasuredDimension(width, height); } else { super.onMeasure(imageWidth, imageHeight); } }