0
我想我String
URL鏈接在TextView
點擊TextView的自動鏈接屬性使得網址,文字隱藏
,我使用這些屬性:
android:autoLink="web"
android:linksClickable="true"
但是字符串的URL隱藏在Textview,但它是可點擊的,並且可以正常打開網址 所以問題出在哪裏,我想鏈接到這樣的文字http://example.com
編輯:XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/row"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:paddingEnd="20dp"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:paddingStart="20dp"
android:paddingTop="5dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/pic"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true">
<TextView
android:id="@+id/_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingEnd="8dp"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:paddingStart="8dp"
android:paddingTop="4dp"
android:paddingBottom="4dp"
android:textSize="16sp"
android:maxWidth="250dp"
android:textColor="@android:color/white"
android:autoLink="web"
android:linksClickable="true"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:gravity="end"
android:orientation="horizontal"
android:paddingBottom="2dp"
android:paddingEnd="4dp"
android:paddingLeft="4dp"
android:paddingRight="4dp"
android:paddingStart="4dp">
<TextView
android:id="@+id/date_and_time_tv"
android:layout_width="wrap_content"
android:layout_height="15dp"
android:layout_marginRight="5dp"
android:layout_marginEnd="5dp"
android:textColor="@android:color/white"
android:layout_gravity="center_vertical"
android:textSize="12sp" />
<ImageView
android:id="@+id/sent_indicator_iv"
android:src="@drawable/ic_done_white_36dp"
android:tint="@android:color/white"
android:layout_width="20dp"
android:layout_gravity="center_vertical"
android:layout_height="15dp" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
我也注意到,如果textview
包含一個URL文本,網址是隱藏的,但其他文本串聯一個普通的文本顯示正常!
你能張貼滿'TextView'或封閉佈局的XML? 'android:autoLink =「web」'將按預期工作,字符串的可見性聽起來像是問題。 – abest
它是可見和有色的,非網址字符串顯示正常,檢查編輯 –