我正在尝试通过使用 WebView
并使用 HTML 格式化字符串资源来证明文本的合理性,如在某些示例中所见:
<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 拒绝解析字符串文档并出现以下错误:
W/ResourceType( 2612): Bad XML block: header size 296 or total size 6144712 is larger than data size 0
这里有什么问题吗?
最佳答案
njzk2是对的,<和>是禁止直接作为字符串使用的。但是,您可以将 HTML 包装在 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>
关于android - 字符串资源中的 HTML,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18146981/