Android 加载大图像以适应ImageView

Android 加载大图像以适应ImageView,android,android-imageview,picasso,Android,Android Imageview,Picasso,我想将最小尺寸约为1800px宽、1400px高的图像加载到imageview中,如下图所示: <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="10dp"> <CheckBox android:id="@+id/customiseCheckBox" a

我想将最小尺寸约为1800px宽、1400px高的图像加载到imageview中,如下图所示:

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:padding="10dp">

    <CheckBox
        android:id="@+id/customiseCheckBox"
        android:layout_width="40dp"
        android:layout_height="40dp"
        android:button="@drawable/custom_checkbox_bkg"
        android:layout_centerVertical="true" />

    <ImageView
        android:id="@+id/customizeSelImg"
        android:layout_width="match_parent"
        android:layout_height="180dp"
        android:layout_marginRight="5dp"
        android:layout_toRightOf="@id/customiseCheckBox"
        android:contentDescription="@string/app_name"
        android:scaleType="fitCenter"
        tools:src="@drawable/artcard" />

</RelativeLayout>
但这似乎不起作用。是否有任何方法可以在不压缩或质量损失的情况下将完整图像显示到imageview的指定尺寸?多谢各位

我正在尝试适合的示例图像:

您需要根据设备重量X高度找到图像比率,然后可以动态设置图像高度重量

public void setHeightWidthFromDeviceScreen() {
        DisplayMetrics displayMetrics = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
        int height = displayMetrics.heightPixels;
        int width = displayMetrics.widthPixels;

        //set banner height using ratio
        int bannerHeight = (int) (width / 1.8014705882);

       //set height to image
        imgSlider.getLayoutParams().height = bannerHeight;


    }
1.8014705882
这是我基于metrics.heightPixels、metrics.widthPixels的图像比率,您可以根据需要更改它

求图像的定量

DisplayMetrics metrics = context.getResources().getDisplayMetrics();
float ratio = ((float)metrics.heightPixels / (float)metrics.widthPixels
);

加载如此大的图像会降低性能,我建议您将相同的图像缩小为recyclerview项目的缩略图,然后单击它们,启动质量更好的图像,请解释更多。我尝试增加imageview尺寸,但图像大小仍然相同。我想增加图像以适应imageview维度中的值大小和维度是两件不同的事情,您不会仅仅将其放置在imageview中而减小图像大小,您将需要压缩它或缩小图像分辨率您可以发布输出图像和您试图适应的图像吗?我添加了示例图像。如果我在线压缩它,它会适合imageview吗?
DisplayMetrics metrics = context.getResources().getDisplayMetrics();
float ratio = ((float)metrics.heightPixels / (float)metrics.widthPixels
);