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 limit the lines?如何限制行数? #59

Open
TimLoong opened this issue Jul 7, 2017 · 1 comment
Open

How to limit the lines?如何限制行数? #59

TimLoong opened this issue Jul 7, 2017 · 1 comment

Comments

@TimLoong
Copy link

TimLoong commented Jul 7, 2017

The PM let me limit the content to 2 lines,so how can I do it?Thanks.
产品需要限制显示2行,怎么限制呢?谢谢~

@TimLoong
Copy link
Author

TimLoong commented Jul 7, 2017

1).手动在attrs.xml增加
attr name="atg_maxRow" format="integer"

2).在 public TagGroup(Context context, AttributeSet attrs, int defStyleAttr) 增加
maxRow = a.getInt(R.styleable.TagGroup_atg_maxRow, Integer.MAX_VALUE);

3).在onMeasure修改.
if (rowWidth > widthSize) {// Next line.
if (++row == maxRow) {
break;
}
rowWidth = childWidth; // The next maxRow width.
height += rowMaxHeight + verticalSpacing;
rowMaxHeight = childHeight; // The next maxRow max height.
}

即可在使用时设置 app:atg_maxRow="2" 限制行数为2.

@TimLoong TimLoong closed this as completed Jul 7, 2017
@TimLoong TimLoong reopened this Jul 7, 2017
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

1 participant