Need to add it to textview, for example, standard java-code.
Asked
Active
Viewed 188 times
1 Answers
2
What do you exactly mean? You may want to change Typeface
of TextView
to monospace
, this will make your TextView look similar to code block here at stackoverflow.
This font is monospace
Code to make it look like this:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:typeface="monospace"
android:text="This font is monospace" />
or in Java:
yourTextview.setTypeface(Typeface.MONOSPACE, Typeface.NORMAL);
Edit:
So, you need some Java code formatting library, the best would be if it returned result in HTML code, so it could be easily put into TextView
.
I don't know if there is something like this for free, but here are few resources you may be interested in:
How to pretty print XML from Java?
Stand-alone Java code formatter/beautifier/pretty printer?
Edit2:
You may also use one of these JavaScript libraries:
along with custom WebView
to show pretty formatted code.

Community
- 1
- 1

Marcin Milejski
- 479
- 3
- 9