Android Multiscreen Support in android : 540x960 issue

跟風遠走 提交于 2019-12-17 19:36:38

问题


My application is supporting 3 type of density ldpi (120),mdpi(160),hdpi(320) and for that we have three folder for resources (ldpi,mdpi,hdpi).

But my problem is occurring in HTC sensation XE (540x960) having density ~256 dpi.and my resources is stretched.

In manifest file

<supports-screens android:xlargeScreens="false" /> 

means i am not supporting for xlarge screen so does 540x960 come in high density??. How can i overcome this problem???

Android Multiscreen Support issue says "You can also use a combination of density and size qualifiers but that still leaves some room for two different resolutions falling into the same bucket."

What should be the name of drawble folder for this kind of resolution?? or is there any other way to short out this issue.

EDIT : My problem is not with layout, my problem 540x960 come in HDPI but my hdpi drawbles are designed related to 480x800

Help me..

Thanks in advance..


回答1:


Your problem is that you have designed your bitmaps for a particular screen size rather than screen density.

Plainly put, you should not do that. There are a huge number of different form factors and screen sizes out there, and you cannot hope to have graphics sized for all of them. So you fix this issue for 540x960 screens... what then with your users who are on 480x854 displays (most hdpi motorola devices)? Will you include different graphics for 1024x720 and 1280x720 displays if you're developing for that? What about 1280x800?

Granted - it can be a pain to deal with these issues, but that is the price we pay for diversity of devices. And Google has provided a fair amount of powerful tools at our disposal to deal with this.

When you are designing an app for Android, you need to think of the design as if you were designing a website - not a desktop (or IOS) program. All (or most) of the tricks that you use for designing a website also apply here - plus you have the density-awareness and 9.patch tools.

And if you really cannot adjust your graphics/layout to the screen without messing it up, you can always center the layout on the display (or align it left or right, depending on what you think looks best).


Edit:

As I mention above, the core to flexible UI design in Android is to think of your app like a web site. Roman Nurik has an article discussing this on the Android blog.

http://android-developers.blogspot.com/2011/09/thinking-like-web-designer.html

Apart from that, it is mostly covered by the Android site, etc.

http://developer.android.com/training/multiscreen/index.html

Using the right layouts and 9-patch images (not always - sometimes static images are better) will allow you to create designs that look good on all phones. But you have to realize that - like a website designed in a browser - you do not and can not have 100% control over how things are displayed on every single device. What you need to achieve is that it is still accessible and good-looking even when displayed on a device that you did not anticipate beforehand.




回答2:


you can use below combination for Layout for HTC sensation XE (540x960) :

res/layout-w540dp-h960dp/layout.xml 

this will use for pick layout for this device and for drawable it will pick image from hdpi because in this developer site 256 dp come in range of hdpi . http://developer.android.com/guide/practices/screens_support.html.

hope this will help you.




回答3:


You have to name the drawable as per your pixel density and the screen size. The calculation is here...

dpi = sqrt (540^2+960^2) / 4.3"(Device size) = ~256 dp = px / (dpi / 160) = 540 / (dpi / 160) = 330

The drawable will be named as drawable-sw330dp. I have tested this. And this works good. No problem with other drawables either. Layout Will be layout-sw330dp

Or you can try this by drawable-sw540p. I haven't tested it yet. But I guess it will work good. Layout Will be layout-sw540p



来源:https://stackoverflow.com/questions/10481073/android-multiscreen-support-in-android-540x960-issue

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