3

I have a long text message followed by a link and have put this inside a TextView. It's simply 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 the whole text becomes highlighted. How can this be prevented ?

alt text

sazwqa
  • 135
  • 1
  • 9
  • Just to clarify I used linkify to do this, that didn't worked. I even tried setting a custom regex to just parse a part of text, that didn't worked too. – sazwqa Oct 06 '10 at 19:37
  • Maybe just an emulator issue? Did you try it on a real device? – ShadowGod Oct 07 '10 at 09:20
  • Yes I did and I saw that this happens with stock API Demos too. Strange the behavior looks odd to me. There are definitely work-arounds but I just wanted to know If I'm missing something here. – sazwqa Oct 07 '10 at 18:13
  • 2
    Were you able to resolve this? I am having the same issue and am looking for a solution. – Sheehan Alam May 25 '11 at 15:35

2 Answers2

0

Nothing, including android:textColorHighlight, had any effect but

textView.setHighlightColor(Color.TRANSPARENT);

worked for me.

0

Not sure if this is still needed. This should prevent the wierd highlighting effect for a textview with links. You should be able to set these in XML as well.

textview.setCursorVisible(false);
textview.setFocusableInTouchMode(false);
eyespyus
  • 1,576
  • 19
  • 20