TextView 中的行号、代码突出显示
我正在为 Android 开发一个“IDE”——它对于编辑短脚本/对文件进行快速调整可能很有用。目前我只使用一个简单的 EditText,但我想添加几个功能,例如 EditText 左侧的行编号和代码突出显示。
有人对如何解决这个问题有任何建议吗?对于代码突出显示,我猜我需要编写自己的 EditText 子类。对于行编号,我可以有一个与 EditText 具有相同文本大小的细垂直 TextView 吗?
是的,我知道在移动设备大小的屏幕上编辑代码很痛苦。
谢谢!
I'm working on an 'IDE' for Android - it could be useful for editing short scripts / making quick adjustments to files. At the moment I'm just using a simple EditText, but I am wanting to add several features, for example Line Numbering down the left hand side of the EditText and Code Highlighting.
Does anyone have any suggestions about how to approach this? For the code highlighting, I'm guessing I'll need to write my own subclass of EditText. For the line numbering, could I have a thin vertical TextView that has the same text size as the EditText??
Yes, I'm aware editing code on a mobile sized screen is painful.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
股票电子邮件应用程序使用 html 视图 (android.webkit.WebView )甚至可以将文本电子邮件包装在 html 中。也许将代码渲染为 html 并在 WebView 中显示将是获得语法突出显示的好方法。
对于行编号,EditText 旁边的细 TextView 似乎很合理。你可能想将它封装到你自己的 View 类中,该类处理两个子视图 - 并允许打开和关闭行号(也许还可以做其他好事,例如保持两者的文本大小相等)
我认为 Android 的 ide 是一个很好的选择主意。如果能够在飞机上编码而无需涉及托盘桌,那就太好了 =)
The stock Email application uses an html view (android.webkit.WebView) to wrap even text emails in html. Perhaps rendering the code into html and displaying in a WebView would be a good way to get syntax highlighting.
For line numbering, the thin TextView beside the EditText seems reasonable. You might want to encapsulate it into your own View class that handles both subviews - and allows line numbers to be turned on and off (and perhaps does other good things like keep text size of both equal)
I think an ide for Android is a good idea. Would be nice to be able to code on an airplane without having to get the tray table involved =)