Android Picasso resize() 不一致

Android Picasso resize() not consistent

我正在使用 Picasso 调整我 Android 界面上的背景图片。

我正在拉伸图像的宽度以填充宽度,但我无法调整高度,因为背景图像需要与中间的圆形图像对齐。

问题在于,在不同的设备上,高度似乎会随着背景的位置不一致而调整。我会 post 举个例子,但我不能,因为我还没有 10 个声望。

这是我的java

ImageView imgBackground = (ImageView) v.findViewById(R.id.imgBackground);
aParent = (MainActivity) getActivity();

//Picasso.with(getActivity()).load(R.drawable.morn_blur_bg).fetch();
Picasso.with(aParent.getApplicationContext())
        .load(R.drawable.morn_blur_bg)
        .resize(aParent.getBackgroundWidth(), aParent.getBackgroundHeight())
        .into(imgBackground);

这是我的 XML

<ImageView
    android:id="@+id/imgBackground"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:scaleType="center"
    android:layout_alignParentTop="true" />

非常感谢任何帮助。

事实证明,在 picasso 做了它的事情之后,imageview 正在拉伸图像。

我尝试设置图像视图高度,但 OS 覆盖了我。

最后我设置了imageView.scaletype="matrix",现在它不拉伸我的图像了

希望对其他人有所帮助,我在这上面花了很多时间。

在我的例子中,我将 android:scaleType="centerCrop" 放在我的 ImageView 上,然后不需要通过 Picasso 应用 centerCrop()。