位图图像未填充宽度

Bitmap image not filling width

我的位图图像无法填充父宽度。

ImageView imgView = (ImageView) getLayoutInflater().inflate(R.layout.image_layout, null);
imgView.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.WRAP_CONTENT));
imgView.setScaleType(ImageView.ScaleType.FIT_XY);
imgView.setAdjustViewBounds(true);
imgView.setImageBitmap(fileBitmap);

但是当我在 imgView.setImageBitmap(fileBitmap); 中使用相同的图像设置 imgView.setImageResource(R.drawable.img); 时,我得到了所需的结果。 下面是我的 image_layout

<?xml version="1.0" encoding="utf-8"?>
<ImageView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:adjustViewBounds="true"
    android:scaleType="fitXY"
    android:clickable="true"/>

我不知道还能做什么

好的,我明白了……我不得不调整图像的大小以适应屏幕宽度

//after declaring my variables
displayMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
width = displayMetrics.widthPixels;

if(width > fileBitmap.getWidth()) {
    int newWidth = width;
    int newHeight = width * fileBitmap.getHeight() / fileBitmap.getWidth();
    fileBitmap = Bitmap.createScaledBitmap(fileBitmap, newWidth, newHeight, false);
}