Search code examples
androidresizepicasso

Android Picasso resize() not consistent


I am using Picasso to resize my background images on my Android interface.

I am stretching the width of the image to fill the width, but I cannot adjust the height, as the background image needs to line up with the circular image in the middle.

Problem is that on different devices, the height appears to adjust as the background is not positioned consistently. I would post an example but I can't as I dont have 10 reputation yet.

Here is my 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);

And this is my XML

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

Any help is greatly appreciated.


Solution

  • It turns out that the imageview was stretching the image after picasso did its thing.

    I tried to set the imageview height, but the OS overrode me.

    In the end I set imageView.scaletype="matrix", and now it does not stretch my image.

    hope that helps someone else, i've spent a lot of time on this.