I have 5-10 lines of address information that I want to insert in a layout in my Android app. I rather not use seperate textviews, but want to have one where I can insert line breaks manually.
I do this by adding \n and it seems to work, BUT.. This also adds padding or a space, I'm not sure which one.
Example:
This XML
<string name="contact_address">
Street address\n
City\n
Country
</string>
Gives this output:
Street address
City
Country
Anyone know what could be wrong, or do I have to give up and make 5-10 seperate textviews?
Try:
<string name="contact_address">Street address\nCity\nCountry</string>
to get rid of the spaces you are putting into your XML.
I stumbled upon this and figured out a better way to keep the XML formatting and the line breaks without additional padding.
Use
<string>Line 1
\nLine 2
\nLine 3
</string>
Instead of
<string>Line 1\n
Line 2\n
Line 3
</string>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With