TextView gets highlighted after using linkify or autolink

I have a long text message followed by a link and put it in a TextView. It is just like this:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content" android:layout_height="wrap_content">
    <LinearLayout android:orientation="vertical"
        android:layout_width="wrap_content" android:layout_height="wrap_content">
        <TextView android:id="@+id/details" android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:padding="10dp"
            android:text="@string/message" android:textSize="16sp" android:autoLink="web"/>
    </LinearLayout>![alt text][1]
</ScrollView>

The problem is when I select the link, all the text will be highlighted. How can this be prevented?

alt text

+3
source share
2 answers

Not sure if this is still necessary. This should prevent the wierd highlighting effect for text with links. You must also install them in XML.

textview.setCursorVisible(false);
textview.setFocusableInTouchMode(false);
0
source

Nothing, including android: textColorHighlight, had any effect, but

textView.setHighlightColor(Color.TRANSPARENT);

worked for me.

0
source

Source: https://habr.com/ru/post/1768305/


All Articles