I have a RecyclerView with TextViews that could contain custom hashtags that should be clickable. So I have created subclass of TextView in which using Pattern I create ClickableSpan. In order for ClickableSpan to be active, I have added
setMovementMethod(LinkMovementMethod.getInstance())
This method changes properties of TextView:
setFocusable(true);
setClickable(true);
setLongClickable(true);
Click on links works, but it prevents ripple drawable to be shown on list item, and click on TextView outside of hashtags are ignored.
So I'm interested how can I redirect touches on TextView (all except on hashtag) to it's parent?
So I haven't found solution on the internet so I ended up implementing it by myself.
So instead of using simple TextView with MovementMethod, I created a new class extending text view with onTouchEvent.
Also I created a class that extends ClickableSpan which handles clicks:
And I this case I have to manage spans by myself (in
setText()
method)