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

Set max lines on FlowLayout #13

Open
amsiddh opened this issue Mar 2, 2015 · 3 comments
Open

Set max lines on FlowLayout #13

amsiddh opened this issue Mar 2, 2015 · 3 comments

Comments

@amsiddh
Copy link

amsiddh commented Mar 2, 2015

How can we set max lines on the FlowLayout. Say for example if we need to show only first 3 lines, can you help me how to achieved this.

@blazsolar
Copy link
Owner

At the moment this is not supported, you could hardcode view height if your lines are always the same height but this is a dirty hack.

I was already thinking about this feature but it had some unanswered questions so id didn't work on it yet. The man problem here is how to handle items that are not visible in the view. Should we just ignore them or should we make view scrollable? Maybe add additional item at the end of last visible line that would expand view? Thoughts?

@manishkungwani
Copy link

I would say that making it scrollable would be preferable over a "View More.." button.. Let me know if I can help with that.

@amsiddh
Copy link
Author

amsiddh commented Mar 20, 2015

My requirement is to show in one of the screen only two lines of items and when user moves to its detail screen show all items. Therefore in this case we can ignore the additional items, so "View More..." is not needed for now.

I tried this

// added after line 45
private int mMaxNumberLines = -1;

//at line 251 updated - inside onLayout
int numLines = (mMaxNumberLines != -1) ? mMaxNumberLines :  mLines.size();

// added after line 398 - to set max lines
public void setMaxNumberLines(int numLines) {
        mMaxNumberLines = numLines;
}

before adding items to flowlayout dynamically, calling setMaxNumberLines with required num of lines.
It is laying out items properly with set lines, but the FlowLayout container is already measured its height for all items. So it shows items with set num lines with empty space for other lines.
Can anyone help me out how to remove that empty space or any other way to achieve this?

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

No branches or pull requests

3 participants