带有多行提示的 EditText
我有一个大的 EditText
框。我希望框中的提示看起来像这样(不是有意的语法突出显示):
Hint about the first line
Hint about the second line
Hint about the third line
我尝试在 EditText
上使用 android:hint="@string/hints"
以及在 strings.xml 中,但提示仍然在一行上。
<string name="hints">
Hint about the first line
Hint about the second line
Hint about the third line
</string>
如何在 EditText
中获取多行提示?
I have a large EditText
box. I want a hint in the box to look like this (syntax highlight not intended):
Hint about the first line
Hint about the second line
Hint about the third line
I tried using android:hint="@string/hints"
on the EditText
with the following in strings.xml, but the hint was still on a single line.
<string name="hints">
Hint about the first line
Hint about the second line
Hint about the third line
</string>
How can one obtain a multiline hint in an EditText
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以通过显式指定在字符串中包含换行符:
XML 中的换行符被视为空格。
You can include newlines in strings by explicitly specifying them:
Newlines in the XML are treated as spaces.
为每一行创建一个单独的字符串资源:
不要在布局 XML 中包含
android:hint
属性。在创建EditText
的位置,手动设置提示:Make a separate string resource for each line:
don't include an
android:hint
attribute in your layout XML. Where theEditText
is created, set the hint manually: