假设我在TextView中有以下文字:
Hey there, visit www.example.com
如果我设置TextView的属性autoLink ="all",将正确检测www.example.com.但是,如果我现在触摸TextView,TextView的文本不是链接('嘿那里,访问'部分)将变灰.有没有办法防止这种行为?
谢谢!
War*_*zit 11
在xml中,您可以简单地执行以下操作:
设置文本颜色:
android:textColor="@color/yourcolor"
Run Code Online (Sandbox Code Playgroud)
设置链接的颜色:
android:textColorLink="@color/yourcolor"
小智 6
如果你可以通过代码而不是XML来实现它,下面的技巧对我来说很有用,即使它有点多余.您基本上将文本颜色设置为现在的颜色.它不像其他人所说的那样"白"; 它是一片灰色.无论颜色如何,都可以获得它并再次设置它.
final TextView message = new TextView(TheApp.this);
final SpannableString s = new SpannableString("Some text with example.com in it.");
message.setText(s);
...
message.setTextColor(message.getTextColors().getDefaultColor());
...
Linkify.addLinks(message, Linkify.WEB_URLS);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8106 次 |
| 最近记录: |