I have a multi-line TextView in Android which has a copy option on long press.
When the user presses on copy, this is the cody I execute:
ClipboardManager clipboard = (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("Answer", tv_answer.getText().toString().trim() + "");
clipboard.setPrimaryClip(clip);
My TextView holds text like - "this is a long text which spans all of three lines" and shows "this is a long ..." because I've set android:ellipsize="end"
.
The problem is, tv_answer.getText()
will return the whole text that I'm setting to my TextView. I only need the text before the ellipses.
I need some guidance with using tv_answer.getLayout().getEllipsisCount()
or tv_answer.getLayout().getEllipsisStart()
or something similar to only get the text before the ellipses.