回答:
はい、デフォルトでAndroidは縦横比を維持しながらImageViewに合わせて画像を縮小します。ただし、android:src="..."ではなくを使用して画像をImageViewに設定していることを確認してくださいandroid:background="..."。src=アスペクト比を維持しながら画像を拡大縮小しますが、ImageViewのサイズに正確に合うようにbackground=拡大縮小して画像を変形させます。(ただし、背景とソースを同時に使用できます。これは、1つのImageViewを使用してメイン画像の周りにフレームを表示する場合などに役立ちます。)
またandroid:adjustViewBounds、ImageView自体がサイズ変更された画像に合わせてサイズ変更されることも確認してください。たとえば、通常は正方形のImageViewに長方形の画像がある場合、adjustViewBounds = trueを指定すると、ImageViewのサイズも長方形に変更されます。これは、ImageViewの周囲に他のビューがどのように配置されるかに影響します。
その後、Samuhが書いたように、android:scaleTypeパラメータを使用してデフォルトで画像を拡大縮小する方法を変更できます。ちなみに、これがどのように機能するかを発見する最も簡単な方法は、少し自分で実験することでした!Eclipseでのプレビューは通常間違っているため、エミュレーター(または実際の電話)でレイアウトを確認することを忘れないでください。
image.setImageDrawable(...)もandroid:src="..."xmlに含まれています。
                    android:adjustViewBounds私のパズルの最後のピースでした、ありがとう!
                    を参照してくださいandroid:adjustViewBounds。
ドローアブルのアスペクト比を維持するためにImageViewの境界を調整する場合は、これをtrueに設定します。
この特定の問題を抱えている他の人に。あなたはImageViewそれにfill_parent比例してスケーリングされた幅と高さを持ちたいと思っています:
これらの2つの属性をに追加しますImageView。
android:adjustViewBounds="true"
android:scaleType="centerCrop"
ImageView幅をにfill_parent、高さをに設定しwrap_contentます。
また、画像をトリミングしたくない場合は、次のことを試してください。
 android:adjustViewBounds="true"
 android:layout_centerInParent="true"
              View)」を除く。AFAICT他のビューにはadjustViewBounds、scaleType属性はありません。
                    ImageView適切なアスペクト比を維持しながら拡大と縮小の両方が必要な場合は、これをXMLに追加します。
android:adjustViewBounds="true"
android:scaleType="fitCenter"
これをコードに追加します。
// We need to adjust the height if the width of the bitmap is
// smaller than the view width, otherwise the image will be boxed.
final double viewWidthToBitmapWidthRatio = (double)image.getWidth() / (double)bitmap.getWidth();
image.getLayoutParams().height = (int) (bitmap.getHeight() * viewWidthToBitmapWidthRatio);
これが機能するまで少し時間がかかりましたが、画像が画面の幅よりも小さく、画面の幅よりも大きい場合、および画像をボックス化しない場合の両方で機能するようです。
ImageView.ScaleTypeを見て、でサイズ変更が行われる方法を制御および理解してくださいImageView。画像のサイズを変更すると(アスペクト比を維持したまま)、画像の高さまたは幅がImageViewの寸法より小さくなる可能性があります。  
これは、ConstraintLayout内での動作です。
<ImageView
    android:id="@+id/myImg"
    android:layout_width="300dp"
    android:layout_height="300dp"
    android:scaleType="fitCenter"
    android:adjustViewBounds="true"/>
次に、コードで、ドロアブルを次のように設定します。
ImageView imgView = findViewById(R.id.myImg);
imgView.setImageDrawable(ResourcesCompat.getDrawable(getResources(), R.drawable.image_to_show, null));
これは、アスペクト比に応じて画像にうまくフィットし、中央に保ちます。
画面よりも小さい画像です。最大に比例して拡大し、ビューの中央に配置するには、次のコードを使用する必要がありました。
<ImageView
    android:id="@+id/my_image"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_centerInParent="true"
    android:adjustViewBounds="true"
    android:layout_weight="1"
    android:scaleType="fitCenter" />
ただし、相対的なレイアウトがあり、いくつかの要素がImageViewの上または下に設定されている場合は、画像と重なる可能性が高いことに注意してください。
画質が低下した場合:使用
android:adjustViewBounds="true"
の代わりに
android:adjustViewBounds="true"
android:scaleType="fitXY"
              画像を適切なスケーリングでトリミングせずに正確に画像ビューに合わせたい場合
imageView.setScaleType(ScaleType.FIT_XY);
ここで、imageViewは、ImageViewを表すビューです。
画面幅を計算できます。また、ビットマップを拡大縮小できます。
 public static float getScreenWidth(Activity activity) {
        Display display = activity.getWindowManager().getDefaultDisplay();
        DisplayMetrics outMetrics = new DisplayMetrics();
        display.getMetrics(outMetrics);
        float pxWidth = outMetrics.widthPixels;
        return pxWidth;
    }
画面幅と画面幅によってスケーリングされた画像の高さを計算します。
float screenWidth=getScreenWidth(act)
  float newHeight = screenWidth;
  if (bitmap.getWidth() != 0 && bitmap.getHeight() != 0) {
     newHeight = (screenWidth * bitmap.getHeight()) / bitmap.getWidth();
  }
ビットマップを拡大縮小した後。
Bitmap scaledBitmap=Bitmap.createScaledBitmap(bitmap, (int) screenWidth, (int) newHeight, true);
              android:layout_gravityImageViewに使用してみてください。
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="center_vertical|center_horizontal"
android:layout_weight="1"
上記の例は私のために働いた。
私はこれを使います:
<ImageView
android:id="@+id/logo"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerInParent="true"
android:scaleType="centerInside"
android:src="@drawable/logo" />
              cardview丸めに使用してヘッダーimageviewを修正した場合、android:layout_heightこれは私が画像をロードするのに役立ちましたGlide
    <?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
             xmlns:tools="http://schemas.android.com/tools"
             android:layout_width="match_parent"
             android:layout_height="220dp"
             xmlns:card_view="http://schemas.android.com/apk/res-auto"
             >
    <android.support.v7.widget.CardView
            android:id="@+id/card_view"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center|top"
            card_view:cardBackgroundColor="@color/colorPrimary"
            card_view:cardCornerRadius="10dp"
            card_view:cardElevation="10dp"
            card_view:cardPreventCornerOverlap="false"
            card_view:cardUseCompatPadding="true">
        <ImageView
                android:adjustViewBounds="true"
                android:maxHeight="220dp"
                android:id="@+id/iv_full"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:scaleType="fitCenter"/>
    </android.support.v7.widget.CardView>
</FrameLayout>
              画像のサイズを縮小する画像を拡大縮小できます。ダウンロードして使用できるライブラリがあります。 https://github.com/niraj124124/Images-Files-scale-and-compress.git
使用方法1)compressor-v1.0をインポートします。プロジェクトにjarします。2)以下のサンプルコードを追加してテストします。ResizeLimiter resize = ImageResizer.build(); resize.scale( "inputImagePath"、 "outputImagePath"、imageWidth、imageHeight); あなたの要件に応じてより多くの方法があります
ImageViewを渡し、画面の高さと幅に基づいて作成できます
    public void setScaleImage(EventAssetValueListenerView view){
        // Get the ImageView and its bitmap
        Drawable drawing = view.getDrawable();
        Bitmap bitmap = ((BitmapDrawable)drawing).getBitmap();
        // Get current dimensions
        int width = bitmap.getWidth();
        int height = bitmap.getHeight();
        float xScale = ((float) 4) / width;
        float yScale = ((float) 4) / height;
        float scale = (xScale <= yScale) ? xScale : yScale;
        Matrix matrix = new Matrix();
        matrix.postScale(scale, scale);
        Bitmap scaledBitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true);
        BitmapDrawable result = new BitmapDrawable(scaledBitmap);
        width = scaledBitmap.getWidth();
        height = scaledBitmap.getHeight();
        view.setImageDrawable(result);
        LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) view.getLayoutParams();
        params.width = width;
        params.height = height;
        view.setLayoutParams(params);
    }
              素早い回答:
<ImageView
        android:id="@+id/imageView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:scaleType="center"
        android:src="@drawable/yourImage"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />
              imageView.setImageBitmap(Bitmap.createScaledBitmap(bitmap, 130, 110, false));
              
setImageBitmap同じであるandroid:src="..."とsetBackground...であるandroid:background="..."