Does anyone know of syntax highlighting libraries which work on Android? I’ve looked at jsyntaxpane but that doesn’t seem to support Android.
Does anyone know of syntax highlighting libraries which work on Android? I’ve looked at
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
For read-only syntax highlighting, you have two options:
Find a Java library that can syntax highlight and generate HTML using
<font color="">(i.e., no CSS). You can then useHtml.fromHtml()to create aSpannedobject which you can hand to aTextView.Find a Java library that can syntax highlight and generate any sort of HTML. You can then display that in a
WebView. This appears to be what theandroid-codepadproject a commenter linked to does.If you are seeking syntax highlighting for an editor, that is significantly more difficult. While
EditTextcan take the sameSpannedthatTextViewcan, you would have to run everything through the syntax highlighter to reflect changes, either on a per-keystroke basis, or after a pause in typing. Or, you would need to bake the syntax highlighting rules much more tightly to the editing process, so you can somehow incrementally adjust the highlighting without having to redo the entire contents of theEditText. I have not seen an open source syntax-highlighting editor for Android — a few closed-source ones as apps on the Play Store, though.