I'm trying to justify text by using a WebView
and formatting a String resource with HTML as saw in some example:
<string name="dTxt">
<html>
<head></head>
<bodystyle text-align:justify=""><body> Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Nunc pellentesque, urna nec hendrerit pellentesque, risus massa </body>
</bodystyle>
</html>
</string>
ADT refuses to parse the Strings document with following error:
W/ResourceType( 2612): Bad XML block: header size 296 or total size 6144712 is larger than data size 0
What is wrong here?
njzk2 is right, < and > are forbidden to use them directly as string. However, you can wrap the HTML in CDATA:
<string name="dTxt">
<![CDATA[
<html>
<head></head>
<bodystyle text-align:justify="">
<body> Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Nunc pellentesque, urna nec hendrerit pellentesque, risus massa
</body>
</bodystyle>
</html>
]]>
</string>
在java代码中尝试使用Html.fromHtml(source)
这些字符串Resource
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.