I have a TextView
embedded in a RelativeLayout
, embedded in a ScrollView
, and I load a Spanned
text object in it created from some HTML code.
I have set the android:autoLink
attribute of the TextView
to true, and I have tested in another part of the application that I can click on links in the text and they will take me to the target website.
The only difference is that this time the TextView
is a child of a ScrollView
. Does that screw up the android:autoLink
process or am I really missing something here?
XML Code:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent" android:layout_width="fill_parent"
android:padding="10dp" android:background="#FFF">
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="wrap_content" android:id="@+id/RLNewsItem">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_alignParentLeft="true"
android:id="@+id/TVText" android:textColor="#000"
android:layout_below="@+id/TVTitle" android:linksClickable="true"
android:autoLink="web|email|map"></TextView>
</RelativeLayout>
</ScrollView>
Java code:
Spanned newsText = Html.fromHtml(htmlsource, this, null);
text.setText(newsText);
Try this Code in String.xml :
Code in Java class: