私はソースコードを読んだだけで、ImageViewこのスレッドでサブクラス化ソリューションを使用しないと基本的に不可能です。ではImageView.onMeasure、私たちは、これらの行を取得します:
        // Get the max possible width given our constraints
        widthSize = resolveAdjustedSize(w + pleft + pright, mMaxWidth, widthMeasureSpec);
        // Get the max possible height given our constraints
        heightSize = resolveAdjustedSize(h + ptop + pbottom, mMaxHeight, heightMeasureSpec);
ここで、hとは、w画像の大きさであり、p*パディングです。
その後:
private int resolveAdjustedSize(int desiredSize, int maxSize,
                               int measureSpec) {
    ...
    switch (specMode) {
        case MeasureSpec.UNSPECIFIED:
            /* Parent says we can be as big as we want. Just don't be larger
               than max size imposed on ourselves.
            */
            result = Math.min(desiredSize, maxSize);
つまり、layout_height="wrap_content"設定されている場合widthSize = w + pleft + pright、つまり、最大幅は画像の幅と同じになります。
つまり、正確なサイズを設定しない限り、画像は決して拡大されません。私はこれをバグだと考えていますが、Googleに知らせて修正してもらうように頑張ってください。編集:自分の言葉を食べて、バグレポートを提出しましたが、将来のリリースで修正されると言われています!
別の解決策
ここにサブクラス化された別の回避策がありますが、(理論的には、実際にはあまりテストしていません!)どこでも使用できるようにする必要がありますImageView。それを使用するにはlayout_width="match_parent"、セット、およびlayout_height="wrap_content"。これも、受け入れられているソリューションよりもかなり一般的です。たとえば、高さに合わせるだけでなく幅に合わせることができます。
import android.content.Context;
import android.util.AttributeSet;
import android.widget.ImageView;
// This works around the issue described here: http://stackoverflow.com/a/12675430/265521
public class StretchyImageView extends ImageView
{
    public StretchyImageView(Context context)
    {
        super(context);
    }
    public StretchyImageView(Context context, AttributeSet attrs)
    {
        super(context, attrs);
    }
    public StretchyImageView(Context context, AttributeSet attrs, int defStyle)
    {
        super(context, attrs, defStyle);
    }
    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
    {
        // Call super() so that resolveUri() is called.
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        // If there's no drawable we can just use the result from super.
        if (getDrawable() == null)
            return;
        final int widthSpecMode = MeasureSpec.getMode(widthMeasureSpec);
        final int heightSpecMode = MeasureSpec.getMode(heightMeasureSpec);
        int w = getDrawable().getIntrinsicWidth();
        int h = getDrawable().getIntrinsicHeight();
        if (w <= 0)
            w = 1;
        if (h <= 0)
            h = 1;
        // Desired aspect ratio of the view's contents (not including padding)
        float desiredAspect = (float) w / (float) h;
        // We are allowed to change the view's width
        boolean resizeWidth = widthSpecMode != MeasureSpec.EXACTLY;
        // We are allowed to change the view's height
        boolean resizeHeight = heightSpecMode != MeasureSpec.EXACTLY;
        int pleft = getPaddingLeft();
        int pright = getPaddingRight();
        int ptop = getPaddingTop();
        int pbottom = getPaddingBottom();
        // Get the sizes that ImageView decided on.
        int widthSize = getMeasuredWidth();
        int heightSize = getMeasuredHeight();
        if (resizeWidth && !resizeHeight)
        {
            // Resize the width to the height, maintaining aspect ratio.
            int newWidth = (int) (desiredAspect * (heightSize - ptop - pbottom)) + pleft + pright;
            setMeasuredDimension(newWidth, heightSize);
        }
        else if (resizeHeight && !resizeWidth)
        {
            int newHeight = (int) ((widthSize - pleft - pright) / desiredAspect) + ptop + pbottom;
            setMeasuredDimension(widthSize, newHeight);
        }
    }
}