Question

I'm building an app and I'm adjusting the sizes between two specific tablets: Sony XPeria Tablet Z and Samsung Galaxy Tab 3 10.1.

I created a template for the XPeria in AVD Manager like this: Tablet Z template

Now, on the layout view, I click on the small "android sheet" on the top left of the design window enter image description here and click on "Create new...".

There I see the option "sw901dp" in the new window to set it as a selector enter image description here

Now, I also have a sw800dp folder for Galaxy Tab 3. The problem is that during runtime, the XPeria Tablet is returning the values from sw800dp instead from sw901dp. During the preview it fetches from the right folder. Explaining this will also allow to explain why Galaxy Tab is fetching from sw800dp in preview and sw600dp in runtime...

Was it helpful?

Solution

Well, doing the math, Eclipse seems to be right.

Given these dimensions (10.1", 1920x1200), the screen has a density of 224 dpi, which is closest to tvdpi. 1200px at tvdpi is indeed 901dp, so that works out fine.

Do getResources().getDisplayMetrics() to see what Android thinks of the actual device. In particular, you're interested in densityDpi, widthPixels and heightPixels. It's possible that the device targets a different density than the one suggested by Eclipse, which might lead to problems like this.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top