javascript - I want to display the contents of html file (with formatting) on TextView in android -
this html file want display on textview :
<html> <head> <link rel="stylesheet" href="highlight/styles/default.css"> <script src="highlight/highlight.pack.js"></script> <script>hljs.inithighlightingonload();</script> </head> <body> <h1>c program calculate area of circle</h1> <p class="test"><pre><code class="c">#include<stdio.h> int main() { area = 3.14 * radius * radius; printf("\narea of circle : %f", area); } </code></pre></p> <br> <!--output--> <div><br>enter radius of circle : 2.0<br> area of circle : 6.14<br> </div> </body> </html>
it has external linking .js , .css files
i've stored in assets folder.
htmlcontentinstringformat=""; string htmlfilename = "www/"+filename; assetmanager mgr = getbasecontext().getassets(); inputstream in = mgr.open(htmlfilename, assetmanager.access_buffer); htmlcontentinstringformat = streamtostring(in); in.close();
i'm using mtextview.settext(html.fromhtml(htmlcontentinstringformat)), displaying plain text. want proper stylized text, displayed when open .html file :
please me.
html.fromhtml()
let view light weight html
in textview
:
mytextview.settext(html.fromhtml(htmlcontentinstringformat));
if want js , css work it, need use webview
. load html
file assets webview
may refer answer here.
Comments
Post a Comment