Referencing image in assets from HTML not working

后端 未结 2 1233
一生所求
一生所求 2021-01-14 01:17

I\'m trying to display an image in a WebView in an Android app. The image exists in the assets folder of my Android project. The HTML is programmatically built and has this

2条回答
  •  盖世英雄少女心
    2021-01-14 01:57

    OK, I finally figured this out. Apparently there is a bug somewhere in the Android code where it fails if the image path has a space in it. So:

    
    

    will fail to load the image. If you change it to:

    
    

    it will work (assuming you've renamed the directory).

    Note:

    • this is only a problem when reading from the assets.
    • appears to be an issue with Android 4.x. I have encountered this issue on 4.0.4 and 4.3 versions but spaces work just fine in 2.3.x version.

    Come on Google, spaces in directory names have been common for 15 years. Get with the program.

提交回复
热议问题