Как мне оформить ссылки autoLink = "web"? - PullRequest
3 голосов
/ 14 мая 2011

У меня есть следующее TextView:

<TextView android:id="@+id/theFooBar"
          android:autoLink="web"
          android:layout_height="wrap_content"
          android:layout_width="fill_parent"
          android:text="@string/fooBar"
          android:textColor="@android:color/black"
          android:textSize="20sp"/>

И строка:

<string name="fooBar">Foo <u>bar</u>.</string>

Это дает мой черный подчеркнутый текст. Что делать, если я хочу синий не подчеркнутый текст для ссылки (часть «bar»), но я хочу, чтобы остальная часть (часть «foo») была черной? Как мне этого добиться?

Ответы [ 2 ]

3 голосов
/ 12 декабря 2013

Добавить Android: textColorLink в TextView, чтобы определить цвет текста для ссылок

1 голос
/ 14 мая 2011

Я рекомендовал вам использовать WebView вместо TextView в этой ситуации:

WebView web = (WebView) findViewById(R.id.theFooBar);
String str = "<font color='blue'>bar</font><font color='black'><u>foo</u></font>";
web.setBackgroundColor(0);
// It will sets the background color from white to transparent. 
web.loadData(str, "text/html", "utf8");
...