I use this excellent hashtag lib: https://github.com/danylovolokh/HashTagHelper
However, there is a bad behavior in this case:
hello it's my last #word
If the last ClickableSpan matchs with the last word in the TextView, then if I don't click in this hashtag but in the TextView (at the end), the click on this hastag is done!
Here you are with this screenshot: the blue rectangle is my TextView; the red cross is a click inside this TextView but not on my last hashtag #word.
In this library, there is this method to specify an hashtag. In my example, nextNotLetterDigitCharIndex variable value is 23 (this value is correct).
if (nextNotLetterDigitCharIndex != -1) {
Spannable s = (Spannable) mTextView.getText();
CharacterStyle span;
if (mOnHashTagClickListener != null) {
span = new ClickableForegroundColorSpan(mHashTagWordColor, this);
} else {
// no need for clickable span because it is messing with selection when click
span = new ForegroundColorSpan(mHashTagWordColor);
}
s.setSpan(span, startIndex, nextNotLetterDigitCharIndex, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
Ps : in nominal mode, this TextView contains several lines.
I have met the same issue. My solution is just adding a space char after the last clickableSpan.