Android Studio automatically erase extra spaces in txt files

It's not really a programming question, but it's a Android Studio specific question.

I am working on the lyrics for a song, and I was asked to add chords to the songs, which I do. So I have songs formatted like this; I have chords on 1 line and lyrics on the next. In order for the chords and lyrics to display correctly, I need the chord line to be the same length as the text line. This usually involves adding a few spaces at the end of the chord line to match the length. But I noticed that Android Studio automatically erases all the necessary spaces at the end.

Any suggestions on what I could have done?

+2


source to share


2 answers


There is a way to add spaces

to your strings.xml

file with double quotes . Please refer to doc

<string name="my_space_string">"    This will work perfectly   "</string>

      

or just use UTF code to add spaces.



<string name="my_space_string">\u0020\u0020This will work perfectly.\u0020\u0020</string>

      

Hope this helps you.

+2


source


You may need to replace spaces with unicode space characters \u0020

.

Eg <string name="name">Text\u0020</string>

.



Or, as Vinot noted, just surround the text with quotes and add your spaces.

+1


source







All Articles