Loading an Android Resource into a WebView

后端 未结 2 522
借酒劲吻你
借酒劲吻你 2020-11-29 20:12

I have an Android app that displays a comic book. To make use of the built-in zoom controls, I am loading the pictures in a WebView like so:

webView.loadUrl(         


        
相关标签:
2条回答
  • 2020-11-29 21:01

    from this site

    Using the resource id, the format is:

    "android.resource://[package]/[res id]"
    
    Uri path = Uri.parse("android.resource://com.androidbook.samplevideo/" + R.raw.myvideo);
    

    or, using the resource subdirectory (type) and resource name (filename without extension), the format is:

    "android.resource://[package]/[res type]/[res name]"
    
    Uri path = Uri.parse("android.resource://com.androidbook.samplevideo/raw/myvideo");
    
    0 讨论(0)
  • 2020-11-29 21:08

    I also had to use loadDataWithBaseURL instead of just plain loadData to get the file:///android_res/drawable/page1.jpg to work.

    0 讨论(0)
提交回复
热议问题