TextView中段落之间的距离

问题描述:

我使用TextView来显示文本,它由几个段落组成。事情是这样的:TextView中段落之间的距离

<TextView 
    android:text="@string/foo" 
/> 

<resources> 
    <string name="foo">Great Gauss! - cried Klapaucius - And where are the gruncheons? Where my dear, favorite pritons? Where now the gentle zits?!\nThey no longer are, nor ever will exist again - the machine said calmly - I executed, or rather only began to execute, your order...</string> 
<resources> 

我怎样才能改变不影响(一个段落的多条线路之间的距离)行间段落之间的距离?

编辑: 也许我不够精确。是的,我知道,因为我用“\ n”换行,我可以 - 比喻 - 用“\ n \ n”做两个换行符。或者使用HTML做这两个换行符。但是,我正在寻找一种方法来确定,例如,段落之间的空间恰好是17倾角。就像我可以(为例)做CSS:

p { 
    margin-bottom: 21px; 
} 
+0

使用这种\ n在字符串 – 2012-08-17 11:22:39

+0

我认为摇滚是对的,但是,伸出澄清之间的下一行,该建议是添加额外\ n在段落之间放置一个空行。如果你想更多的控制使用HTML如下。 – 2012-08-17 11:28:52

+0

您可以使用Spannables来实现此目的:http://*.com/a/42691246/1073151 – 2017-03-10 05:35:35

可以使用的,而不是像这样

Textview.setText(Html.fromHtml(" This portion Contains text with <b>html<b> <br/> <p> tags and others as per your requirement.</p> ")); 

希望这有助于你正常的文本HTML文本...

你可以考虑为您的字符串使用HTML。这也将有利于让您使用粗体,斜体的额外好处等

在strings.xml,你需要使用下面的代码<>

&lt; &gt; 

含义“少比'和'大于'。以下代码将< br/>作为额外的行。

<resources> 
    <string name="foo">Great Gauss! - cried Klapaucius - And where are the gruncheons? Where my dear, favorite pritons? Where now the gentle zits?! &lt;br/&gt;They no longer are, nor ever will exist again - the machine said calmly - I executed, or rather only began to execute, your order...</string> 
<resources> 

设置你的TextView仍然比较相似,

message = getString(R.string.foo); 
textView.setText(Html.fromHtml(message));