4

I have a very long string in my strings.xml which is displayed in a TextView with ~10 lines. The string contains an url. The url must be completely displayed in 1 single line. Line breaks before or after the url, but currently it breaks my url after "www."

The url is shorter than the space of the line, that's not the problem. The TextView looks like this:

lalala lululu blabli luli blub
lalabla blu blablo blabl www.
this-is-my-url.com bla.

and it should look like this:

lalala lululu blabli luli blub
lalabla blu blablo blabl 
www.this-is-my-url.com bla.

on other displays it also must not look like this:

lalala lululu blabli luli blub lalabla blu blablo 
blabl 
www.this-is-my-url.com bla.

this could happen when I try a newline before the link

I hope you see my problem

4

4 回答 4

1
use android:autoLink="web" in textView in layout.and use \t before or after link.
于 2013-05-13T12:15:48.787 回答
0

在 url 之前添加一个换行符。

<string name="hello">lalala lululu blabli luli blublalabla blu blablo blabl \n www.this-is-my-url.com bla</string>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<TextView
    android:id="@+id/tvTest"
    android:text="@string/hello"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />

于 2013-05-13T12:39:02.907 回答
0

Try to insert "\n" before and after your url: Try this: lalala lululu blabli luli blub lalabla blu blablo blabl\nwww.this-is-my-url.com bla.\n

于 2013-05-13T12:09:20.807 回答
0

您可以在一行的最后一个单词到达边缘之前强制换行,这个解决方案对我有用。 https://gamedev.stackexchange.com/a/50550/154846

于 2021-08-03T09:52:44.510 回答