android - String资源中的HTML

Dro*_*man 4 android android-xml

我试图通过WebView在一些示例中使用和格式化带有HTML的String资源来证明文本是正确的:

     <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>
Run Code Online (Sandbox Code Playgroud)

ADT拒绝解析Strings文档,但有以下错误:

  W/ResourceType( 2612): Bad XML block: header size 296 or total size 6144712 is larger than data size 0
Run Code Online (Sandbox Code Playgroud)

这有什么不对?

Mar*_*rqs 11

njzk2是对的,<和>被禁止直接用作字符串.但是,您可以将CD包装在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>
Run Code Online (Sandbox Code Playgroud)