I want to write table(matrix) with jqmath but the output is not correct .
I copy jqmath example .
there is my code :
webView = (WebView) findViewById(R.id.wv);
WebSettings settings = webView.getSettings();
settings.setJavaScriptEnabled(true);
String path="file:///android_asset/mathscribe/";
String js = "<html><head>"
+ "<link rel='stylesheet' href='"+path+"jqmath-0.4.3.css'>"
+ "<script src='"+path+"jquery-1.4.3.min.js'></script>"
+ "<script src='"+path+"jqmath-etc-0.4.3.min.js' charset=\"utf-8\"></script>"
+ "</head><body>"
+ "<script>var s = '$(\\table \\ cos θ, - \\sin θ; \\sin θ, \\cos θ)$ gives a rotation by $θ$';M.parseMath(s);document.write(s);</script>"
+ "</body>";
webView.loadDataWithBaseURL("file:///android_asset/mathscribe/", js, "text/html", "UTF-8", null);
the output is linear matrix like below :
I suggest that combine slash and t (\t)in " var s = '$( \table \ cos θ, - \sin θ; \sin θ, \cos θ) " cause this problem because the t character is gone and first line moved to right.
How I can solve this problem?
SOlVED
if I replace every slash with 4 slash the result is correct ....
I think it's best to replace the line:
+ "<script>var s = '$(\\table \\ cos θ, - \\sin θ; \\sin θ, \\cos θ)$ gives a rotation by $θ$';M.parseMath(s);document.write(s);</script>" +
with:
+ "$(\\table \\cos θ, - \\sin θ; \\sin θ, \\cos θ)$ gives a rotation by $θ$" +
or:
+ "$(`table `cos θ, - `sin θ; `sin θ, `cos θ)$ gives a rotation by $θ$" +
Related
I am using Jsoup to get the text from an html doc and display it in my android app.
The text cotains a list (<ul><li>).
If I do it like this I get only the text:
val doc = Jsoup.parse(someHtml)
return doc.text()
I tried using wholeText:
val doc = Jsoup.parse(removeImages)
return doc.wholeText()
In this way it keeps some formatting, but still it ignores the bullet points. Is there any way to get the bullet points in the text?
The bullets are rendered by the browser, so they are not a part of the text.
You'll have to add it by yourself, like in this example:
String html = "<html>" +
"<head>" +
"<title>List</title>" +
"</head>" +
"<body>" +
"<ul>" +
"<li>Item 1</li>" +
"<li>Item 2</li>" +
"<li>Item 3</li>" +
"</ul> " +
"</body>" +
"</html>";
Document doc = Jsoup.parse(html);
Element list = doc.select("ul").first();
Elements item = list.children();
for (Element e : item) {
System.out.println("\u2022" + e.text());
}
The output is:
•Item 1
•Item 2
•Item 3
You can replace the bullet with any other character that you like, by replacing the \u2022 code with any other valid code/character.
I have certain text in the web view. I can select those text . I want to highlight those text but I have no idea how to do it. Anyone having any idea about it, please help! Thanx!
you need to run java script
public static String Highlightscript = " <script language=\"javascript\">" +
"function highlightSelection(){" +
"var userSelection = window.getSelection();" +
"for(var i = 0; i < userSelection.rangeCount; i++)"
+ " highlightRange(userSelection.getRangeAt(i));" +
"}" +
"function highlightRange(range){"+
"span = document.createElement(\"span\");"+
"span.appendChild(range.extractContents());"+
"span.setAttribute(\"style\",\"display:block;background:#ffc570;\");"+
"range.insertNode(span);}"+
"</script> ";
and
webView.loadUrl("javascript:highlightSelection()");
make sure you enabled javascript
WebView myWebView = (WebView) findViewById(R.id.webview);
WebSettings webSettings = myWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
In Android 4.1(jellybean), WebView.findAll() is deprecated, we should use WebView.findAllAsync instead.
reference
Wish this help:)
I am trying to display geo map using google's visualization in android's webview
My web view settings are as follows -
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setUseWideViewPort(true);
webView.requestFocusFromTouch();
webView.requestFocus(View.FOCUS_DOWN);
webView.getSettings().setLoadWithOverviewMode(true);
webView.setInitialScale(getScale());
//webView.setWebViewClient(new WebViewClient());
webView.setWebChromeClient(new WebChromeClient());
// String containing js to draw map using google's Visualization:Geochart
String js = "<html><head>" +
"<script type='"+"text/javascript"+"' src='"+"https://www.google.com/jsapi"+"'></script>"+
"<script type='"+"text/javascript"+"'>" +
"google.load('"+"visualization"+"', '"+"1"+"', {packages:['"+"geomap"+"']});" +
"google.setOnLoadCallback(drawRegionsMap);" +
" function drawRegionsMap() {" +
" var data = google.visualization.arrayToDataTable([" +
"['Country', '"+name+"']," + build +
"]);" +
"var options = {colors: ['"+startColor+"', '"+endColor+"']};" +
"var chart = new google.visualization.GeoChart(document.getElementById('regions_div'));" +
"chart.draw(data, options);" +
"}" +
"</script>" +
"</head>" +
"<body bgcolor='#E6E6FA'>" +
"<div id='"+"regions_div"+"' style='"+"width:100%; height: 100%;"+"'></div>" +
"</body>" +
"</html>";
The code is working fine . I get different regions of map with different colors. But I need that only web view get translated in landscape mode by keeping default screen orientation of fragment (activity) as POTRAIT . Also when I click on region a popup displays the proper name of country, but popup also opens outside the region on click on any where in the map. Even I tried on chrome browser in mobile it has same problem. Where as the same visualization is working fine on normal web browser on computer.
I have a webview which has a p tag inside and the webview itself is has 90% of the device width by default, but I want that p tag to have a 100% width to fill the whole webview. I tried giving it via style:
<p style="width:100%"></p>
but this throws UnknowFormatConversionException. Here is my code to fill the webview with content:
String head = "<head><style>#font-face {font-family: 'byekan';src: url('fonts/BYekan.ttf');}body {font-family: 'Tahoma';}</style></head>";
String text = "<html>" + head + "<body style=\"background:#e4322f;min-height:" + minHeight + "\"><p style=\"width:100%;background:blue;direction:" + dir + ";font-family:byekan;color:#fff;text-align:justify;float:" + flt + "\"> %s </p></body></Html>";
wv.loadDataWithBaseURL("file:///android_asset/",String.format(text, _content), "text/html", "utf-8", null);
it works fine if I remove that "width:100%", but the p tag will takes the text width but I want it to fill the webview width, how can I achieve that? thanks in advance.
I have set custom font in Webview using
String html = "<html><head><title></title> "
+ "<style type=\"text/css\"> "
+ "#font-face { font-family:'GEORGIA'; src: url('file:///android_asset/GEORGIA.TTF'); }"
+ "body { font-family: 'GEORGIA'; text-align: justify;}"
+ "</style> "
+ "</head><body >"
+ "<div>"
+ "<p>"
+ data + "</p></div></body></html>";
webview.loadDataWithBaseURL("",html,"text/html", "utf-8", "");
It is set font but problem is that in data i have text like heading contents when i run it then heading is not display bold.
Maybe your font does not contain bold characters.
True Type Fonts (TTF) can contain a subset of all available characters.
Did you copy the ttf-file from your systems fontpath?
If not, you can open the font with a tool like font-explorer,