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

How to dynamically control item width #23

Closed
zhangle1 opened this issue Jun 1, 2017 · 3 comments
Closed

How to dynamically control item width #23

zhangle1 opened this issue Jun 1, 2017 · 3 comments

Comments

@zhangle1
Copy link

zhangle1 commented Jun 1, 2017

I want to get the screen width -10dp as the width of item,
I tried doing it in onCreateViewHolder:
viewHolder= new viewHolder(_inflate);
ViewGroup.LayoutParams _layoutParams = viewHolder.mCardView.getLayoutParams();
layoutParams.width=_layoutParams.width-10;
viewHolder.mCardView.setLayoutParams(_layoutParams);
But it doesn't work.

@sevar83
Copy link

sevar83 commented Jun 1, 2017

I could suggest you to use match_parent as the item size and then apply the min/max scale. But you'll have to calculate the desired scale based on the measured item size.

@zhangle1
Copy link
Author

zhangle1 commented Jun 2, 2017

thanks,I still have some questions about how I should control the position of item so that the second item can display an optional value

@yarolegovich
Copy link
Owner

Probably related to #20

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

No branches or pull requests

3 participants