@NonNull
    public static Rect scaleImageToLineHeight(final Drawable drawable, final TextView view) {
        final int lineHeight = (int) (view.getLineHeight() * 0.8);
        final int width = drawable.getIntrinsicWidth() * lineHeight / drawable.getIntrinsicHeight();
        return new Rect(0, 0, width, lineHeight);
    }
Image that automatically scales to fit a line of text in the containing {@link TextView}.
main/src/main/java/cgeo/geocaching/utils/ImageUtils.java