How to add line spacing after every "\n" in a string in android?
<p>As the question is clearly stated, I want to add a small line spacing after every <code>\n</code> defined in a string in a resource file in Android.</p>

<p>Let's say we have a string defined in xml like this:</p>

<pre><code>&lt;string name="line_test"&gt;This is the 1st line. This is still the 1st line.\nThis is the 2nd line.\nThis is the 3rd line. This is still the 3rd line.\nThis is the 4th line.&lt;/string&gt;
</code></pre>

<p>The normal output when setting it to a <code>TextView</code> will be like the left side of this image. What I want to achieve is the right side of this image.</p>

<p><a href="https://i.stack.imgur.com/oSwGn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oSwGn.png" alt="Image 1"></a></p>

<p>There are some attributes in xml like:</p>

<pre><code>android:lineSpacingMultiplier="2"
</code></pre>

<p>and</p>

<pre><code>android:lineSpacingExtra="10dp"
</code></pre>

<p>but these attributes will only lead to something like this:</p>

<p><a href="https://i.stack.imgur.com/Sk8Xu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Sk8Xu.png" alt="Image 2"></a></p>

<p>So I don't want to add line spacing after every new line because the width of the line is consumed, but only after every defined <code>\n</code>.</p>

<p>Any way to achieve what I want through code or html? By saying html, I mean something like this, but with some modified stuff after adding <code>&lt;br/&gt;</code>:</p>

<pre><code>textView.setText(Html.fromHtml("This is the 1st line. This is still the 1st line.&lt;br/&gt;This is the 2nd line.&lt;br/&gt;This is the 3rd line. This is still the 3rd line.&lt;br/&gt;This is the 4th line."));
</code></pre>

<p>It is more like I want to create many paragraphs in the <code>TextView</code> with small line spacing after each paragraph all in one string. I thought that this would be possible to be done through HTML, so that's why I added html tag.</p>

<hr>

<p><strong>Edit:</strong></p>

<p>I also don't want to add two line breaks because I only want a small line spacing, and putting two line breaks together will have a large line spacing, which I don't want due to some design issues in my app.</p>