@Android display /res/viewable in WebView

前端 未结 7 1438
耶瑟儿~
耶瑟儿~ 2020-11-29 05:51

I am throwing HTML to a webview to render. In the HTML I need to load an image that I have in /res/drawable.

I have /res/drawable/my_image.png

7条回答
  •  遥遥无期
    2020-11-29 06:30

    You load the drawables like you would anywhere else in your code... http://developer.android.com/guide/topics/resources/drawable-resource.html

    Resources res = getResources();
    Drawable drawable = res.getDrawable(R.drawable.myimage);
    

    also @MikeNereson using Android, you can only directly access raw files that are located in the assets directory and SDCard.

提交回复
热议问题