2016-11-22 62 views
0

我想我String URL鏈接在TextView點擊TextView的自動鏈接屬性使得網址,文字隱藏

在XML

,我使用這些屬性:

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文本,網址是隱藏的,但其他文本串聯一個普通的文本顯示正常!

+0

你能張貼滿'TextView'或封閉佈局的XML? 'android:autoLink =「web」'將按預期工作,字符串的可見性聽起來像是問題。 – abest

+0

它是可見和有色的,非網址字符串顯示正常,檢查編輯 –

回答

0

加入這個屬性android:textColorLink解決我的問題