Tuesday, 16 October 2018

TextView doesn't allow to select text after the application is paused

I have a TextView where a user can select text.

Problem: Selection works well unless the application is paused (for instance, after switching apps). Once the app is active again selection stops working and I get the following message in log:

W/TextView: TextView does not support text selection. Selection cancelled.

My setup:

I have an Activity with CoordinatorLayout and a Fragment with a TextView wrapped into RelativeLayout which looks like this:

<TextView
    android:id="@+id/text_view"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentStart="true"
    android:scrollbars="vertical" />

And in Java code I have to do:

textView.setTextIsSelectable(true);
textView.setFocusable(true);
textView.setFocusableInTouchMode(true);

because this was the only working way according to this, this and this issues.

What I tried:

First of all I don't get why it doesn't work that's why it is hard to investigate the problem but I tried making the TextView selectable again in setUserVisibleHint() which though didn't help.



from TextView doesn't allow to select text after the application is paused

No comments:

Post a Comment