I know that setting android:textIsSelectable="true"
in xml for the TextView
will show the native text selection popup and I've been using that in my application. But what I found that it is not working any more when I try to set the same attribute in a view attached to the RecyclerView
. Whenever I try to select the text the following log appears -
TextView: TextView does not support text selection. Action mode cancelled.
And I don't know why? Why it works on other screens and not with the RecyclerView
. I read multiple posts -
TextView with android:textIsSelectable="true" not working in listview
textview textIsSelectable="true" not working in Listview
android:textIsSelectable="true" for TextView inside Listview does not work
But then I encountered this post -
Android: "TextView does not support text selection. Action mode cancelled"
And the reply by @hungkk
worked for me. His solution suggested the TextView
width to change to wrap_content
from match_parent
.
I know I can do this but my question is how this fixed the issue because it looks weird to me. And also, what is the solution if I want to keep the width to match_parent
.
Any inputs are welcome.
In the main-parent layout of recyclerview add attribute
android:descendantFocusability="beforeDescendants"
and then in TextView of rowitem layout add
android:textIsSelectable="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