如何在TextView中实现换行?

3

我之前在论坛上看到过 \n 的使用,但我认为这只是在Java中编程时才能使用的... 实际上 '\n' 在XML中也可以使用!!!希望这能帮到你.....

<TableRow android:id="@+id/originDesc" android:layout_width="fill_parent"

        android:layout_height="wrap_content" android:layout_marginRight="15px"

        >

        <TextView android:id="@+id/widget36"

                android:layout_width="wrap_content" android:layout_height="wrap_content"

                android:text="The Bullmastiff was developed in England by gamekeepers for
protection against poachers. The foundation breeding of the
modern pure-bred was 60 per cent Mastiff and 40 per cent Bulldog.
It is a guard and companion dog, and should be loyal, obedient, and thus suitable for training."

                android:textSize="10sp">

        </TextView>

</TableRow>

我有一个Textview(见下文),我放在里面的文本会自动换行等等,但是,即使翻转水平,文本仍然延伸到屏幕的右侧,显然,行的长度很长,我期望在那一点上仍然是多行的,但仍然延伸了部分单词超出了屏幕的右侧。
有人知道我如何防止这种情况吗?我已经尝试了shrinkColumn="1",一直尝试到30,但没有任何变化,我还尝试了其他几件事情。

你能按照自己的意愿输出吗?我的意思是一行应该显示多少个字符? - Pankaj Kumar
你的TableRow/TableLayout是否在其他ViewGroup中? - Maximus
1个回答

0
从我理解的角度来看,尝试解决您的问题时,请考虑您的文本外观而不是整个 UI…… 您可以使用 android:layout_width="fill_parent" 来填充屏幕宽度,并使用 android:paddingTop、android:paddingLeft、android:paddingRight、android:paddingBottom 来获取左侧、右侧、顶部和底部所需的空间,对于常见的间距,您可以使用 android:padding,并请不要忘记查看您的表格行属性。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接