【问题标题】:TextView link text is not visibleTextView 链接文本不可见
【发布时间】:2020-12-30 15:07:30
【问题描述】:

我有一个TextView,它显示了除链接之外的所有插入文本,但它们应该在的位置仍然是可点击的,并将我带到所需的目的地。什么会使链接本身不可见?

来自字符串资源

<string name="credits">Video from <a href="http://youtube.com">Youtube</a></string>

从布局

<TextView
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:background="@color/colorAccent"
    android:fontFamily="@font/abril_fatface"
    android:lineSpacingExtra="12sp"
    android:paddingLeft="16dp"
    android:paddingTop="75dp"
    android:paddingRight="16dp"
    android:text="@string/credits"
    android:textAlignment="center"
    android:textColor="@color/colorPrimaryDark"
    android:textSize="30sp" />

来自活动

textCredits.movementMethod = LinkMovementMethod.getInstance()

【问题讨论】:

    标签: android kotlin hyperlink textview invisible


    【解决方案1】:

    原因可能是文本颜色和背景相等。尝试使用以下方法为链接设置另一种颜色:

    android:textColorLink="@color/someColor"
    

    【讨论】:

      【解决方案2】:

      使用这样的颜色

      android:textColorLink="#fff"
      

      android:autoLink="true"
      

      【讨论】:

      • 据我了解,你不能同时使用movementMethod和autolink..加上链接没有它。
      猜你喜欢
      • 1970-01-01
      • 2018-11-15
      • 1970-01-01
      • 2021-06-26
      • 2013-07-06
      • 2018-10-24
      • 2011-02-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多