PhoneGap - target-densitydpi on viewport

匿名 (未验证) 提交于 2019-12-03 07:50:05

问题:

I'm creating a app for Android and iOS using PhoneGap.

After creating the "HelloWorld" app from PhoneGap's template I could see the target-densitydpi=device-dpi on the viewport by default. Okay, that's fine for now but I decided to run some tests with JQuery Mobile UI and they do not use target-densitydpi on the viewport (by the way if I do, the website should look very small on high dpi devices).

Since I need the images of my app to look great at low and high resolution devices, I decided to run some tests on my Galaxy S4.


First, target-densitydpi=device-dpi removed:

<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height" /> 

The document.width was 360px, so I created a 360px image and it was really blurry at my GS4 screen.

<img src="360img.jpg" style="width:360px;"> 

Second, target-densitydpi=device-dpi enabled:

<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" /> 

The document.width was 1080px, so I created a 1080px image and it was great at my GS4 screen.

<img src="1080img.jpg" style="width:1080px;"> 

Third, target-densitydpi=device-dpi removed with 1080px image:

<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height" /> 

The document.width was 360px, so I used the previously created 1080px image and it looks great at the GS4 screen.

<img src="1080img.jpg" style="width:100%;"> 

I was able to get the same results on second and third tests, but, wich one is the best (or correct) way to work with PhoneGap Apps?

Thanks!


EDIT1:

I'm thinking about provide these images via API, where I can tell the size of the window to return the correct sized image.

window.width was 1080px at all tests, so return the correct sized image will not be a problem.

For icons, I'm considering SVG, then I don't need to create sprites for each resolution. I can resize de image via CSS or JavaScript and it should still looking good.

What made me think to don't use target-densitydpi=device-dpi was JQuery Mobile UI, they library is responsive and they don't use it, why?


回答1:

target-densitydpi is not supported IOS and deprecated Android. So I suggest do not use it.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!