namito/TagCloudLinkView

Bug regarding tag generation (and fix!)

killingdjef opened this issue · 0 comments

Hi,

Thanks for making this library!

I've encountered a bug. Whenever the first tag is too long and the textview adds ellipsis to the end, adding another tag will make all tags disappear. The error lies at the code that does the tag layout. I've fixed the issue with the following snippet

TagCloudLinkView.java - line 259

if (mWidth <= total + tagWidth + LAYOUT_WIDTH_OFFSET)
{
if(index>1) //This condition fixes the bug.
{
tagParams.addRule(RelativeLayout.BELOW, pindex);
}
tagParams.topMargin = TAG_LAYOUT_TOP_MERGIN;
// initialize total param (layout padding left & layout padding right)
total = getPaddingLeft() + getPaddingRight();
pindex = index;
}
else
{
tagParams.addRule(RelativeLayout.ALIGN_TOP, pindex);
tagParams.addRule(RelativeLayout.RIGHT_OF, index - 1);
if (index > 1) {
tagParams.leftMargin = TAG_LAYOUT_LEFT_MERGIN;
total += TAG_LAYOUT_LEFT_MERGIN;
}
}