Mateu
Mateu

Reputation: 2698

Android: Picasso image inside a RecyclerView with GridLayoutManager

I want to define an Android screen that has squared images in 3 columns, using the maximum width as possible. I'm using with a RecyclerView that uses a GridLayoutManager and Picasso for loading images.

The problem

I'm not able to make the images as big as possible. I've tried the following:

Picasso.with(context).load(factory.getImage(value)).fit().into(holder.button);

With this I get a correct width, but the height is resized (getting a distorted image)

Picasso.with(context).load(factory.getImage(value)).centerInside().fit().into(holder.button);

With this I get smaller images than what should be.

How can I achieve this?

Thanks,

Upvotes: 2

Views: 1305

Answers (2)

Jerry
Jerry

Reputation: 295

I also faced this problem with images in columns. I wanted them to have the fullest width possible and also fit into let's say 3 or 4 columns. After many experiments I realized I had forgotten to add:

android:adjustViewBounds="true"

to my ImageView. This solved my problem. The images now fit the grid layout perfectly!

Upvotes: 1

Akber
Akber

Reputation: 523

Bitmap img = Picasso.with(this).load("http://").get();
int w = img.getWidth();
int h = img.getHeight();

This will get you orignal height and width of an image, Now may be this would help you in yours context

Upvotes: 0

Related Questions