4

I use TextView to display text, which consists of several paragraphs. Something like this:

<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>

How can I change the distance between paragraphs without affecting interline (distance between many lines of one paragraph)?

Edit: Maybe I was not precise enough. Yes, I know that since I made linebreak with "\n" I could - by analogy - make two linebreaks with "\n\n". Or do these two linebreaks using HTML. But I am looking for a way to decide, for instance, that space between paragraphs shold be exactly 17 dip. Like I can (as example) do in CSS:

p {
    margin-bottom: 21px;
}
user983447
  • 1,598
  • 4
  • 19
  • 36

2 Answers2

2

You can consider using HTML for your string. This would also have the additional benefit of allowing you to use bold, italics, etc.

In your strings.xml, you'll need to use the following codes for < >

&lt; &gt;

Meaning 'less than' and 'greater than'. The following code places a <br/> as an extra line.

<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>

Setting your TextView remains relatively similar,

message = getString(R.string.foo);
textView.setText(Html.fromHtml(message));
pjama
  • 3,014
  • 3
  • 26
  • 27
0

You can use Html text instead of normal text like this

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

Hope this helps you...

MobileEvangelist
  • 2,583
  • 1
  • 25
  • 36