lineCount in recyclerView example
eggham0518 opened this issue · comments
It's working well.
` TextView tv_content = holder.tv_content;
tv_content.setText(strContent);
tv_content.post(new Runnable() {
@Override
public void run() {
int lineCount = tv_content.getLineCount();
if (lineCount < 4) {
return;
}
int start = tv_content.getLayout().getLineStart(0);
int end = tv_content.getLayout().getLineEnd(2);
int lmitLength;
try {
lmitLength = strContent.substring(start, end).length() - 2;
} catch (Exception e) {
return;
}
if (lmitLength < 0) {
return;
}
CustomReadMoreOption readMoreOption = new CustomReadMoreOption.Builder(mContext)
.textLength(lmitLength, ReadMoreOption.TYPE_CHARACTER)
.moreLabel("more")
.lessLabel("less")
.build();
readMoreOption.addReadMoreTo(tv_content, strContent);
}
});``