Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Items that are not ImageViews cause disorted photos #10

Closed
eshkoliGilad opened this issue Mar 3, 2016 · 10 comments
Closed

Items that are not ImageViews cause disorted photos #10

eshkoliGilad opened this issue Mar 3, 2016 · 10 comments

Comments

@eshkoliGilad
Copy link

When I'm trying to wrap ImageView with, say, RelativeLayout, the items becomes disorted.

Why is that ? I want to add views on top of imageView so I need a container but that makes thing look very bad.

Any idea why ?

@eshkoliGilad eshkoliGilad changed the title Items not ImageView cause disorted photos Items that are not ImageViews cause disorted photos Mar 3, 2016
@eshkoliGilad
Copy link
Author

Never mind, got that working.

@tbruyelle
Copy link

@eshkoliGilad I have the same issue, when my ImageView is wrapped with another layout it is disorted. How did you fix that please ?

@eshkoliGilad
Copy link
Author

@tbruyelle

I've just made sizeForChildAtPosition() method of GreedoLayoutManager static and I call it in OnBind in the adapter:

    holder.mImageView.getLayoutParams().width = GreedoLayoutManager.sizeForChildAtPosition(position).getWidth();
    holder.mImageView.getLayoutParams().height = GreedoLayoutManager.sizeForChildAtPosition(position).getHeight();

@tbruyelle
Copy link

@eshkoliGilad Ok so you had to update the library code. In that case your issue is still valid. I opened a similar one here #16

@The-RobinHood
Copy link

@eshkoliGilad It will helpful if you share GreedoLayoutManager class, I'm also struggling to over come this issue.
thanks

@eshkoliGilad
Copy link
Author

eshkoliGilad commented Apr 21, 2016

@The-RobinHood

The only thing I did was setting sizeForChildAtPosition() static and then in you onBind() function just calling:

holder.mImageView.getLayoutParams().width = GreedoLayoutManager.sizeForChildAtPosition(position).getWidth();
holder.mImageView.getLayoutParams().height = GreedoLayoutManager.sizeForChildAtPosition(position).getHeight();

You may consider using this on your main container also if this doesn't help you.

I know it is not the perfect solution, but it was the quickest one.

@The-RobinHood
Copy link

@eshkoliGilad can you share your GreedoLayoutManager class, if you don't mind?

@The-RobinHood
Copy link

@eshkoliGilad hey, it will really helpful to me if you share your GreedoLayoutManager class, I'm stuck with this issue for a week. thanks

@abhimuktheeswarar
Copy link

abhimuktheeswarar commented May 18, 2016

Just change the method to public & static. It works.
@The-RobinHood can u please tell us, how u solved the issue ? #21

@olik79
Copy link

olik79 commented Aug 8, 2016

Just changing the method to static will not work, as it accesses instance variables which of course aren't valid in a static context.

What I did instead was to give the GreedoLayoutSizeCalculator (which can be retrieved by GreedoLayoutManager#getSizeCalculator()) to my adapter. I just added a member variable and a setter. After that you can just do the following within your onBindViewHolder(...) method:

    Size imageViewSize = mSizeCalculator.sizeForChildAtPosition(position);
    holder.itemView.getLayoutParams().width = imageViewSize.getWidth();
    holder.itemView.getLayoutParams().height = imageViewSize.getHeight();

I still don't really like this because I feel like it doesn't really match the concept of adapters and layout managers, but if I remember correctly I didn't have to change any library code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

6 participants