我有一个TextView
嵌入在 a 中 RelativeLayout
,嵌入在 a 中ScrollView
,并且我在其中加载了一个Spanned
从一些 HTML 代码创建的文本对象。我已将 的android:autoLink
属性设置TextView
为 true,并在应用程序的另一部分进行了测试,我可以单击文本中的链接,它们会将我带到目标网站。唯一不同的是,这一次TextView
是 a 的孩子ScrollView
。这会搞砸这个android:autoLink
过程还是我真的在这里错过了什么?
XML 代码:
<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代码:
Spanned newsText = Html.fromHtml(htmlsource, this, null);
text.setText(newsText);