0

There is my ImageView

<ImageView
    android:id="@+id/image"
    android:layout_width="match_parent"
    android:layout_height="150dp" />

I load image to this ImageView using Picasso library.

Picasso.with(getActivity()).load(url)
                            .config(Bitmap.Config.RGB_565)
                            .into(imageView);

There is problem that there is padding inside ImageView and loaded image.

There is image to show padding: Padding

I use .fit() method to avoid this gap, but image stretches and quality losts.

(You can see that this dark-blue circles is ovals now) enter image description here

The question is: What should I do to avoid loosing quality of image and resize it directly to ImageView. I can't add .centerCrop() because left side of image is logical safe-zone. Also I can't change layout_height="150dp" because it will break all my layout.

Anyway thank you!

VLeonovs
  • 2,193
  • 5
  • 24
  • 44

1 Answers1

0

Look at your ImageView:

<ImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="150dp" />

You are forcing the image to stretch to the width of its parent view (the screen maybe?). Try using wrap_content for the width and keeping the height the same. This may cause the image to shrink, but its up to your desired UX.

@stefs found that adding this:

...android:adjustViewBounds="true" />

would help. Check out the post here.

If you want static image sizes, you may have to deal with the padding.

Community
  • 1
  • 1
Frank B.
  • 204
  • 5
  • 17
  • Unfortunately, doesn't helps to me, `android:adjustViewBounds="true" /` ignoring at all – VLeonovs Jan 27 '16 at 17:50
  • @VLeonovs did you try changing the width to `wrap_content` too? – Frank B. Jan 27 '16 at 17:54
  • Ok. Are these images square in shape or rectangular. I think the image is being stretched from what it is originally thats why it is like that. Post the original images so we can see em. – Frank B. Jan 28 '16 at 15:22