There is a TextView inside ListView.
I set maxLine of TextView through codding like bellow.
view.textView.setText("....... Long String.........");
view.textView.post(new Runnable() {
@Override
public void run() {
if(view.textView.getLineCount > 4) {
view.tv_read_more.setVisibility(View.VISIBLE);
view.textView.setMaxLines(4);
}
}
});
Problem : textView.setMaxLine() not working first time.
textView affected after ListView scroll down and scroll up
I have an example in RecyclerView,this is work well.
mDes.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
mDes.getViewTreeObserver().removeOnPreDrawListener(this);
int lineCount = mDes.getLineCount();
Log.e("TreeObserver", "onBind: " + lineCount1);
if (lineCount1 < 4 || isExpand) {
mArrowContainer.setVisibility(View.GONE);
} else {
mArrowContainer.setVisibility(View.VISIBLE);
}
return true;
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With