Search code examples
androidtextviewcolor-scheme

How to create a coloarable TextView on Android (Like IDE)


I want to create a TextView that contains programming language code. like the following picture

sample

I think that I should use html for give color and also will use string functions such as indexof,substring .. firstly, will find "for" and if i find it i will replace it with

  <h3 style="color:blue;margin-left:20px;">for</h3> 

But I am not sure if its the best way or useful.. Do you have any idea to do it on android?

PS: I am not making a compiler, just want to show piece of code

PS2: I am not asking for webview or textview.. Just want to learn how can I do it except my html case. Doesnt matter webview or textview or editview


Solution

  • Thank you for all attention, I've completly found a solution that I want. I've used codemirror library, and found a sample for android.

    you can download the project from code google