Is there any possibility to select (highlight) text in more than one recycler view item at once?

Viewed 136

I am working on android app where I want to implement simple text file reader. I am using recyclerView to show the text. I chose the recyclerView for speed, since when I loaded larger file into one textView, the app crashed. So one line of the file is one item in the recyclerView. Now I'd like to add the text selection and highlight on long click. I have easily managed to do it for one item (one line) - I have added the attribute android:textIsSelectable="true" to the item container. But that logically allows to select only text from one item at once.

Is there any possibility to select text in more than one recycler view item at once?

Thank you in advance.

This is the layout of the reader:

<?xml version="1.0" encoding="utf-8"?>

<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical">

                <androidx.recyclerview.widget.RecyclerView
                    android:id="@+id/file_list_view"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="10dp"
                    android:layout_marginStart="20dp"
                    android:layout_marginEnd="20dp"
                    android:scrollbars="horizontal|vertical"
                    />

        </LinearLayout>

</HorizontalScrollView>

And this is the item layout:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

    <TextView
        android:id="@+id/tv"
        android:layout_weight="1"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:maxLines="1"
        android:textIsSelectable="true"/>

</LinearLayout>

Edit: The result should look like this:

enter image description here

0 Answers
Related