1

URL を持つテキストを含む TextView があります。Linkify を使用して、クリック可能な URL に変換しました。

    Linkify.addLinks(bodyTextView, Linkify.WEB_URLS);

ただし、URL ではないテキストをクリックすると、テキストの色が変わります。これは、テキストビューが 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>
4

2 に答える 2

1

追加:

android:textColor="#ffffff"

xml の TextView 要素に変更すると問題が解決します... textcolor をオーバーライドすると、要素に関連する他の色スタイルがオーバーライドされるようです...この質問を参照してください: Android text view color does not change when disabled

于 2011-05-27T06:22:30.237 に答える