Linkify的奇怪选择行为

| 我有一个带有文本的URL的TextView。我已经使用Linkify将它们转换为可点击的URL:
    Linkify.addLinks(bodyTextView, Linkify.WEB_URLS);
但是,当我单击非URL的文本时,文本颜色会更改。当textview设置为AutoLink时,也会发生这种情况。 这是我的布局:
<?xml version=\"1.0\" encoding=\"utf-8\"?>
<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"
    android:orientation=\"vertical\"
    android:layout_width=\"fill_parent\"
    android:layout_height=\"fill_parent\">
   <RelativeLayout
    android:layout_height=\"wrap_content\"
    android:layout_width=\"fill_parent\"
    android:id=\"@+id/headerLinearLay\"
    android:orientation=\"horizontal\" android:padding=\"4px\">
    <ImageView
        android:id=\"@+id/avatarImageView\"
        android:layout_height=\"48px\" android:layout_width=\"48px\"></ImageView>
    <TextView
        android:id=\"@+id/usernameTextView\"
        android:text=\"TextView\"
        android:paddingLeft=\"4dp\"
        android:layout_toRightOf=\"@id/avatarImageView\"
        android:layout_height=\"wrap_content\"
        android:layout_width=\"wrap_content\"></TextView>
</RelativeLayout>
    <TextView android:text=\"TextView\" android:layout_height=\"wrap_content\" android:id=\"@+id/bodyTextView\" android:textSize=\"24sp\" android:layout_width=\"fill_parent\" android:autoLink=\"web\"></TextView>
    <TextView android:text=\"TextView\" android:layout_height=\"wrap_content\" android:id=\"@+id/dateTextView\" android:layout_width=\"fill_parent\" android:layout_weight=\"1\"></TextView>
    <LinearLayout android:layout_width=\"match_parent\" android:layout_height=\"wrap_content\" android:id=\"@+id/toolbarLinearLayout\" android:background=\"@color/solid_yellow\" android:padding=\"5dip\">
    <Button android:layout_width=\"fill_parent\" android:layout_weight=\"1\" android:layout_height=\"wrap_content\" android:id=\"@+id/replyButton\" android:text=\"Reply\"></Button>
    <Button android:layout_width=\"fill_parent\" android:layout_weight=\"1\" android:layout_height=\"wrap_content\" android:text=\"RT\" android:id=\"@+id/rtButton\"></Button>
    <Button android:id=\"@+id/dmButton\" android:layout_width=\"fill_parent\" android:layout_weight=\"1\" android:layout_height=\"wrap_content\" android:text=\"DM\"></Button>
</LinearLayout>




</LinearLayout>
    
已邀请:
新增:
android:textColor=\"#ffffff\"
到XML中的TextView元素解决了问题...似乎重写textcolor会覆盖与元素相关的其他颜色样式...请参阅此问题:禁用时,Android文本视图颜色不会更改     
这是默认行为。您可以使用android:textColor属性显式设置文本颜色,但是单击链接时看不到任何视觉变化。一种解决方案是将android:textHighlightColor设置为与常规文本颜色匹配。非链接文本保持不变,并且单击链接时您会看到视觉提示(链接的背景变成了其余文本的颜色)。     

要回复问题请先登录注册