单击时,Android TextView 链接不突出显示 [英] Android TextView links don't highlight when clicked

查看:31
本文介绍了单击时,Android TextView 链接不突出显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 android TextView,里面有一个链接.当用户点击链接时,链接看起来不错并且执行正确的操作,但是当用户的手指向下时链接根本不会改变颜色.这是正常的Android行为吗?似乎某种类型的突出显示或指示器会有所帮助,尤其是当我有小文本和一堆彼此相邻的链接时.这是其他人看到的,是否有简单的解决方法?

I have an android TextView which has a link in it. The link looks fine and performs the correct action when the user taps on it, but while the user's finger is down the link doesn't change color at all. Is that normal Android behavior? Seems like a highlight or indicator of some kind would be helpful, especially if I have small text and a bunch of links next to each other. Is this what other people are seeing, is there an easy fix for this?

此外,URL 末尾的斜杠不是链接的一部分.闻起来像他们的 RegEx 中的错误.

Also the slash on the end of the URL isn't part of the link. Smells like a bug in their RegEx.

这是我正在使用的代码:

Here's the code I'm using:

    textView.setAutoLinkMask(Linkify.WEB_URLS);
    textView.setText("Hi welcome to http://www.plopfizz.com/ please enjoy.");

推荐答案

您可以创建一个具有不同状态的项目选择器,例如...

You could create an item selector with diff states, for example...

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="true" android:color="#FEFEFE" /> <!-- highlight -->
    <item android:state_focused="true" android:color="#000000" />
    <item android:color="#FFFFFF" /> <!-- default -->
</selector>

然后在您的布局中...

And then in your layout...

<TextView 
  ...
  android:textColor="@color/above_selector"/>

这篇关于单击时,Android TextView 链接不突出显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆