Android:Android Studio中strings.xml文件的自定义代码折叠

时间:2023-01-14 15:00:33

I have small issue with the strings.xml file, when it is uploaded to a translation website. When the string is long and takes more than one line, Android Studio automatically adds a tab and the rest of the text is on the next line. The translators never know if this is part of the string or not. Is there a way I could prevent strings.xml being automatially indented when the string continues on the next line. Here is an example:

我将strings.xml文件上传到翻译网站时遇到小问题。当字符串很长并且需要多行时,Android Studio会自动添加一个选项卡,其余文本位于下一行。译者永远不知道这是否是字符串的一部分。有没有办法阻止string.xml在下一行继续字符串时自动缩进。这是一个例子:

desired behaviour:

   <string name="one">one string</string>
   <string name="two">second string</string>
   <string name="long_string">kdfajdflJKF DLSKJDLJDF skjLFÑJDLFJDÑL
DAJHFJDKHFKAFK</string>

current behaviour:

    <string name="one">one string</string>
    <string name="two">second string</string>
    <string name="long_string">kdfajdflJKF DLSKJDLJDF skjLFÑJDLFJDÑL
    DAJHFJDKHFKAFK</string>

In the second example, in the file, extra spaces get added before the word DAJHFJDKHFKAFK so how could it prevent this? Where to look? I tried google search but I am not sure even how this feature would be called. What are the options? Thanks

在第二个例子中,在文件中,在单词DAJHFJDKHFKAFK之前添加了额外的空格,那么它怎么能阻止这个呢?去哪儿看?我试过谷歌搜索,但我不确定甚至如何调用此功能。有什么选择?谢谢

2 个解决方案

#1


1  

If you are using Android Studio, go to File -> Settings, in that under Editor -> Code Style -> XML, set Indent = 0 and also, under the Android tab, set Wrap attributes to Do Not Wrap.

如果您使用的是Android Studio,请转到文件 - >设置,在编辑器 - >代码样式 - > XML下,设置Indent = 0,并在Android选项卡下,将Wrap属性设置为Do Not Wrap。

#2


-1  

I am going to just give you an alternative to the way you copy and paste, bet you didn't know this one... Hold down Alt and then drag the mouse over what you want to copy, you would see the beauty there

我只是给你一个替代你复制和粘贴的方式,打赌你不知道这一个...按住Alt然后将鼠标拖过你要复制的东西,你会看到那里的美丽

EDIT: Most translation websites are not built for codes, they are built for ordinary texts. So there is no way of changing that Android Studio feature that I know of, plus if you do edit it, any time you decide to share your code, it is going to look soo ugly with no proper indentation. (While writing this, I figured out that your solution would be to reduce the indent value... To do this, go to File >> Settings >> Search keyword "indent" and mess with stuff that comes up

编辑:大多数翻译网站不是为代码而构建的,它们是为普通文本而构建的。所以没有办法改变我所知道的Android Studio功能,再加上如果你编辑它,任何时候你决定分享你的代码,它会看起来很丑,没有适当的缩进。 (在写这篇文章时,我发现你的解决方案是减少缩进值...为此,请转到文件>>设置>>搜索关键字“缩进”并弄乱出现的内容

#1


1  

If you are using Android Studio, go to File -> Settings, in that under Editor -> Code Style -> XML, set Indent = 0 and also, under the Android tab, set Wrap attributes to Do Not Wrap.

如果您使用的是Android Studio,请转到文件 - >设置,在编辑器 - >代码样式 - > XML下,设置Indent = 0,并在Android选项卡下,将Wrap属性设置为Do Not Wrap。

#2


-1  

I am going to just give you an alternative to the way you copy and paste, bet you didn't know this one... Hold down Alt and then drag the mouse over what you want to copy, you would see the beauty there

我只是给你一个替代你复制和粘贴的方式,打赌你不知道这一个...按住Alt然后将鼠标拖过你要复制的东西,你会看到那里的美丽

EDIT: Most translation websites are not built for codes, they are built for ordinary texts. So there is no way of changing that Android Studio feature that I know of, plus if you do edit it, any time you decide to share your code, it is going to look soo ugly with no proper indentation. (While writing this, I figured out that your solution would be to reduce the indent value... To do this, go to File >> Settings >> Search keyword "indent" and mess with stuff that comes up

编辑:大多数翻译网站不是为代码而构建的,它们是为普通文本而构建的。所以没有办法改变我所知道的Android Studio功能,再加上如果你编辑它,任何时候你决定分享你的代码,它会看起来很丑,没有适当的缩进。 (在写这篇文章时,我发现你的解决方案是减少缩进值...为此,请转到文件>>设置>>搜索关键字“缩进”并弄乱出现的内容