Android Multiscreen Support in android : 540x960 issue

前端 未结 3 1410
一个人的身影
一个人的身影 2020-12-10 08:59

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 occ

相关标签:
3条回答
  • 2020-12-10 09:07

    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.

    0 讨论(0)
  • 2020-12-10 09:12

    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

    0 讨论(0)
  • 2020-12-10 09:16

    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.

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