使用Mathview show math时,我的webview溢出宽度。虽然我在下面的代码中使用“自动换行”。它不起作用。这是我在Mathview lib中的MathJaxWebview类中的代码,对于webview是settext myWebview.setText(content); :
public void setText(final String text) {
loadDataWithBaseURL("http://bar",
"<head>" +
"<style>" +
"img{max-width:100%}\r\n" +
"audio{background:#2888e1;padding:10px;height: 47px;}" +
"</style>" +
"<script type=\"text/x-mathjax-config\">" +
"MathJax.Hub.Config({\n" +
" showMathMenu: false,\n" +
" messageStyle: \"none\",\n" +
" SVG: {\n" +
" scale: 120,\n" +
" linebreaks: {\n" +
" automatic: true\n" +
" }\n" +
" },\n" +
" \"HTML-CSS\": { linebreaks: { automatic: true } },\n" +
" CommonHTML: { linebreaks: { automatic: true } },\n" +
" tex2jax: {\n" +
" inlineMath: [ ['$','$'], [\"\\\\(\",\"\\\\)\"] ]\n" +
" }\n" +
" });" +
"MathJax.Hub.Queue(function () { document.getElementById(\"hide_page\").style.visibility = \"\"; });" +
"</script>" +
"<script type=\"text/javascript\" async src=\"file:///android_asset/MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML\"></script>" +
"" +
"</head>" +
"<body style=\"text-align:justify\">" +
text +
"</body>" +
"</html>", "text/html", "utf-8", "");
}
还有我的字符串
example content math this link
请帮助我,谢谢所有兄弟
答案 0 :(得分:0)
移动此代码:
`" showMathMenu: false,\n" +
" messageStyle: \"none\",\n" +
" SVG: {\n" +
" scale: 120,\n" +
" linebreaks: {\n" +
" automatic: true\n" +
" }\n" +
" },\n" +
" \"HTML-CSS\": { linebreaks: { automatic: true } },\n" +
" CommonHTML: { linebreaks: { automatic: true } },\n" +`
到" tex2jax: {\n" +...
以下。
新代码:
public void setText(final String text) {
loadDataWithBaseURL("http://bar",
"<head>" +
"<meta name='viewport' content='target-densityDpi=device-dpi'/>"+
"<style>" +
"img{max-width:100%}\r\n" +
"audio{background:#2888e1;padding:10px;height: 47px;}" +
"</style>" +
"<script type=\"text/x-mathjax-config\">" +
"MathJax.Hub.Config({\n" +
" tex2jax: {\n" +
" inlineMath: [ ['$','$'], [\"\\\\(\",\"\\\\)\"] ]\n" +
" },\n" +
" showMathMenu: false,\n" +
" messageStyle: \"none\",\n" +
" SVG: {\n" +
" scale: 120,\n" +
" linebreaks: {\n" +
" automatic: true\n" +
" }\n" +
" },\n" +
" \"HTML-CSS\": { linebreaks: { automatic: true } },\n" +
" CommonHTML: { linebreaks: { automatic: true } },\n" +
" });" +
"MathJax.Hub.Queue(function () { document.getElementById(\"hide_page\").style.visibility = \"\"; });" +
"</script>" +
"<script type=\"text/javascript\" async src=\"file:///android_asset/MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML\"></script>" +
"" +
"</head>" +
"<body style=\"text-align:justify\">" +
text +
"</body>" +
"</html>", "text/html", "utf-8", "");
}