行号,在TextView的code高亮 [英] Line Numbers, Code Highlighting in TextView
问题描述
我正在为Android的IDE - 这可能是短期的编辑脚本/制作快速的调整文件很有用。目前,我只是用了一个简单的EditText,但我想增加几个功能,例如行号下的EditText和code高亮的左侧。
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.
有没有人对如何处理这有什么建议?对于code高亮,我猜我需要写我自己的EditText的子类。对于行号,我可以有一个具有相同的文本大小的EditText上??
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??
是的,我是一个手机大小的屏幕上清楚编辑code是痛苦的。
Yes, I'm aware editing code on a mobile sized screen is painful.
谢谢!
推荐答案
该公司股价现应用程序使用HTML视图(的 android.webkit.WebView )来包装甚至文本电子邮件,HTML中。也许渲染code到HTML,并在网页视图显示将有语法高亮的好方法。
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.
有关行号时,旁边的EditText薄的TextView似乎是合理的。你可能想将其封装到自己的视图类,可以同时处理子视图 - 并允许行号被打开和关闭(也许还有其他的做的好东西一样保持文字大小都等于)
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)
我觉得Android的一个IDE是一个好主意。将是不错的能够code在飞机上,而无需获得餐桌参与=)
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 =)
这篇关于行号,在TextView的code高亮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!