PhoneGap的图片 [英] PhoneGap Images
问题描述
我目前正在创建具有的PhoneGap
的的Android
应用程序,我无法插入图片到我的项目。我曾在不同的目录中保存我的PNG文件,也是目前唯一一个问号显示出来在我的形象应该是。我无法从URL中使用的图像无论是。
I am currently creating an Android
application with Phonegap
and I am unable to insert images to my project. I have saved my .png file in different directories and still only a question mark shows up where my image should be. I can not use images from a URL either.
推荐答案
要使用本地图像尝试以下。
To use a local image try the following.
把你的图像中的项目/资产/ www文件夹
Put your image in the /assets/www folder of the project
然后设置图像标签如下:
Then set the image tag as follows:
<img src="../www/myimage.png">
是的,我知道这应该是相同的设置SRC为myimage.png。我不能说,为什么这可能工作的原因,但我不得不与PhoneGap的本地图片的确切同样的问题,这个固定的问题,对我来说。如果你在一个子目录中有他们,你可以尝试将其加入路径:
Yes, I realize this should be the identical to setting the src to "myimage.png". I cannot say the reason why this might work, but I had the exact same problem with local images on Phonegap and this fixed the issue for me. If you have them in a subdirectory, you can try adding this on to the path:
<img src="../www/mydir/myimage.png">
我也发现下面的语法的工作,也许少一些笨拙的寻找:
I also found the following syntax worked, maybe a little less clumsy looking:
<img src="./myimage.png">
或者
<img src="./mydir/myimage.png">
这一切都是在Android 4.0不幸的是,我不知道早期版本的操作系统
This was all on Android 4.0 unfortunately, I do not know for earlier versions of the OS
这篇关于PhoneGap的图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!