小编Ald*_*ndy的帖子

如何将可绘制文件夹中的图像放在HTML文件中

我的/res/raw/test.html中有一个HTML文件

并使用以下代码在Web视图中显示它

WebView wbview = (WebView)findViewById(R.id.webView1);
InputStream fin;
    try
    {
        fin = getResources().openRawResource(R.raw.manual);
        byte[] buffer = new byte[fin.available()];
        fin.read(buffer);
        fin.close();
        wbview.loadData(new String(buffer), "text/html", "UTF-8");
    }
    catch (IOException e)
    {
        e.printStackTrace();
    }
Run Code Online (Sandbox Code Playgroud)

这是我的HTML文件的代码

<html>
    <p>
    Lorem ipsum dolor sit amet,
    </p>
  <table>
   <tr>
         <td>
       <img src=\\"file:///android_asset/test_image2.jpg\"/>    
           <img src="test_image2.jpg" width="50px" alt="Hi">

       <img src=\"res/drawable/test_image.png"/>
       <img src="file:///android_res/drawable/test_image.png" />
       <img src=\"file:///android_res/drawable/test_image.png"\ />
         </td>
   </tr>
</table>
</html>
Run Code Online (Sandbox Code Playgroud)

我想在我的html文件中显示我的资源文件夹中的图像...我尝试了所有可能性仍然无法正常工作.它只显示一个HTML文本,但对于一个图像,我不知道如何显示它

请帮我

android

10
推荐指数
1
解决办法
1万
查看次数

标签 统计

android ×1