
有时,当我加载页面时(没有静态内容,是动态生成的),我看到的字体大小太小了1.如果重新加载,我会看到正确的字体2.来回查看它是否正确.然后…小.不是特定页面,不是特定时间.甚至没有特定的版本:我在ICS设备上部署,没问题,然后更改了某些内容(例如字体大小),这就是问题所在.在8和10个仿真器上部署时也是如此.
我的观点很简单:
<?xml version="1.0" enCoding="utf-8"?><linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:layout_weight="1" androID:orIEntation="vertical" > <WebVIEw xmlns:androID="http://schemas.androID.com/apk/res/androID" androID:ID="@+ID/webvIEwArticle" androID:layout_wIDth="match_parent" androID:layout_height="fill_parent" androID:layout_weight="1" androID:padding="12dp" > </WebVIEw></linearLayout>HTML构造(content参数的格式为HTML)
String toShow = new StringBuffer() .append("<HTML>") .append("<head>") .append("<style type='text/CSS'>body{ Font-size: large; color: #FFFFFF; background-color: #000000;}</style>") .append("</head>") .append(String.format( "<body><h1>%s</h1><div><img src='%s' alt='%s' style='wIDth:100%%; height:auto' /></div><div style='background-color:#000000;'>%s</div><div><h3>%s</h3></div></body>", article.getTitle(), article.getimagelink().toString(), article.getTitle(), article.getContent().replace("%", "%25"), //HTML article.getAuthor())) .append("</HTML>") .toString();mbrowser.getSettings().setBuiltInZoomControls(true);mbrowser.setinitialScale(1);CompatibilityUtils.setLoaDWithOverviewmode(mbrowser, true); //set based on androID versionmbrowser.getSettings().setUseWIDeVIEwPort(true);mbrowser.loadDataWithBaseURL("fake://in/order/to/refresh", toShow, "text/HTML", "utf-8",null);有什么提示吗?
附加说明12/9/25:如图像所示,WebVIEw认为可用空间是屏幕的一半,并相应地放置文本.这很奇怪.最奇怪的是,它对文本(图像上方的标头和下面的div)而不是图像如此认为!!!
解决方法:
WebSettings settings= webVIEw.getSettings();这个
settings.setTextSize(WebSettings.TextSize.SMALLEST);要么
settings.setDefaultFontSize(10);//Larger number means larger Font size 总结 以上是内存溢出为你收集整理的android-WebView文字大小全部内容,希望文章能够帮你解决android-WebView文字大小所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)