2dxgujun/AndroidTagGroup

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

Opened this issue · 1 comments

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

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.