Mxy*_*xyk 2 android indentation android-alertdialog
我相信我以前见过这样的问题,但我无法在任何地方找到它...所以,我会发布我的问题版本,除非别人知道它的链接.
无论如何...
我有一个AlertDialog在我的strings.xml文件中显示一个字符串以显示在对话框中.字符串看起来像这样:
<string name="about_app">
Blah blah blah talking about stuff this is a line
Oh look I continued onto another line! Now I want these...\n\n
So this is another paragraph! Intriguing. Yes, onto the next line
Android text doesn't necessarily consider this a new line, which is fine
becauase i only care about paragraphs, which I'm using backslash n's for!\n\n
And... here's my final statement! Woo.\n
</string>
Run Code Online (Sandbox Code Playgroud)
一切都在AlertDialog中正确显示(有些)."Blah blah blah ......"与它的左边缘对齐AlertDialog并继续直到它击中\n\n.从这里,我得到了我想要的间距"所以这是......".然而,"所以这就是......"缩进了一个令人讨厌的小空间,我无法摆脱它!同样的"而且......这是我的......".有人有解决方案吗?
注意:我已经尝试在代码中的每个段落之后删除空行 - 什么都不做.我也确保在我之后没有空格\n.
您看到的额外空间是由字符串资源中段落的缩进引起的.当你打破这条线时,你的缩进就像是单词之间的断裂,你将它视为空间.但是,当您有一个换行符时,缩进会显示为每个段落开头之前的空格.要摆脱它,你需要将你的\n直接放在下一段的第一个字母之前,或者不要缩进你的行.顺便说一下,换行自身也可能在渲染时产生空间.这两个中的任何一个应该工作:
(1)
<string name="about_app">
Blah blah blah talking about stuff this is a line
Oh look I continued onto another line! Now I want these...\n
\nSo this is another paragraph! Intriguing. Yes, onto the next line
Android text doesn't necessarily consider this a new line, which is fine
becauase i only care about paragraphs, which I'm using backslash n's for!\n
\nAnd...here's my final statement! Woo.\n
</string>
Run Code Online (Sandbox Code Playgroud)
或(2)
<string name="about_app">
Blah blah blah talking about stuff this is a line
Oh look I continued onto another line! Now I want these...\n\n
So this is another paragraph! Intriguing. Yes, onto the next line
Android text doesn't necessarily consider this a new line, which is fine
becauase i only care about paragraphs, which I'm using backslash n's for!\n\n
And...here's my final statement! Woo.\n
</string>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
985 次 |
| 最近记录: |