3

I have developed a clock widget. And I only have 1 res/layout and 1 res/drawable. Everything works perfectly.

It works on mdpi like Samsung Galaxy Ace. It works on hdpi like Samsung Galaxy S2. It works on xhdpi like Samsung Galaxy Note.

However I got ugly look on 720x1280 devices such as Samsung Galaxy Nexus or Sony Xperia S. And coming soon Samsung Galaxy S3.

When I provide res/layout/xhdpi which I built specifically for 720x1280 devices and then Galaxy Note will also use this layout and it looks ugly on Galaxy Note.

How to address this issue?

It is like some crossing between 720x1280 (Galaxy Nexus, Sony Xperia S, Galaxy S3) and 800x1280 (Galaxy Note).

stuckedunderflow
  • 3,551
  • 8
  • 46
  • 63

2 Answers2

5

The resolution and DPI of the device don't necessarily match up (high resolution doesn't mean high DPI). DPI is a ratio of the resolution of the device and its physical dimensions.

Instead of separating your layout folders by DPI, separate them by dimensions. For instance, layout-large, layout-xlarge. You can also quantify by specific sizes, such as layout-w720-h1280, in which case that would match only device with a minimum width of 720 pixels and minimum height of 1280 pixels.

Jason Robinson
  • 31,005
  • 19
  • 77
  • 131
  • Hi Jason, I tried to provide layout-normal, layout-large, layout-xlarge but did not work. When I provide layout-mdpi, layout-hdpi, layout-xhdpi. It works. But as I mentioned earlier Galaxy note and Sony Xperia S will be using the same layout-xhdpi. But they don't match each other. When I fix on Sony Xperia S, Galaxy Note would not aligned. Vice versa. – stuckedunderflow Jun 13 '12 at 05:43
  • I tried to put layout-w720dp-h1280dp and layout-sw720dp but it never get used anyway. Always refers to folder /layout. – stuckedunderflow Jun 13 '12 at 05:44
  • What works and what doesn't work? Those are valid quantifiers, I use them in my projects, so I know they work. And what about the layout differences between devices doesn't look right? – Jason Robinson Jun 13 '12 at 14:25
  • 1
    Hi Jason, layout-normal, layout-large, layout-xlarge did not work. layout-w720dp-h1280dp and layout-sw720dp also did not work. Never get used. What works are layout-mdpi, layout-hdpi, layout-xhdpi. But Samsung Galaxy Note and Sony Xperia S using the same layout-xhdpi. And the layout is different to each other. When I fix on Sony Xperia S, Galaxy Note would not aligned and vice versa. – stuckedunderflow Jun 13 '12 at 22:23
  • Right, but what do you mean they don't work? Did they always use the layout in the `layout` folder instead? If so, you most likely set up the folders incorrect. – Jason Robinson Jun 13 '12 at 23:29
  • "I tried to provide layout-normal, layout-large, layout-xlarge but did not work" - Yes this does not work. Perhaps both Sony Xperia S and Samsung Galaxy Note lies under layout-normal. However the main concern here is why Sony Xperia 720x1280 and Galaxy Note 800x1280 can be so different each other. – stuckedunderflow Jun 14 '12 at 03:04
  • So they do work, it's just not a solution to your problem. You've got me baffled then if that won't give you the results you want. Could you provid more detail in your question about what exactly about the layouts on each device makes them look bad (screenshots)? I might be able to offer a different solution not regarding different layout resources. – Jason Robinson Jun 14 '12 at 15:54
  • Ok I'll try what is missing on my layout. And I'll create another question if I got the issues. – stuckedunderflow Jun 15 '12 at 06:02
  • Can you tell me what value is for any 480*800 device and 720*1280 devices? For example nexus one or such kind of phones and for Galaxy S3, Note II range devices. layout-sw320dp working for Galaxy Nexus – tejas Apr 04 '13 at 11:42
1

Use layout-sw320dp for Galaxy S3

Inco Mob
  • 594
  • 2
  • 7
  • 20