有没有办法在不以编程方式执行的情况下修复 EditText 中每行的字符数?
我只想设置每行的最大字符数,以便单词将换行到下一行。有什么办法可以做到这一点吗?我查看了 EditText 文档,但没有看到明确的方法。
任何帮助表示赞赏
I just want to set the maximum amount of characters per line, so that the words will wrap onto the next line. Is there any way to do this? I looked over the EditText documentation and I don't see a clear way of doing this.
Any help is appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以
在 xml 文件内设置 EditText。一旦达到宽度,这将使文本自动换行到下一行。您必须使用浸入值来看看您想要多大。据我所知,没有办法用字符来衡量这一点。如果您希望视图增长以在键入时显示文本(如果文本比视图长),则还需要将layout_height 设置为“wrap_content”。
You can set
Inside your xml file for the EditText. This will make it wrap the text on to the next line once the width is reached. You'll have to play with the dip value to see how big you want it. As far as I know there is no way to measure this in characters though. You'll need to have the layout_height set to "wrap_content" also if you want the view to grow to show the text as it gets typed, if its longer than your view.
您可以在 xml 中设置
edittext
的 maxlength 属性。you can set maxlength property of
edittext
in our xml.