2

I want to use different layouts for Samsung Galaxy Note (5.3 inch display) and Acer Iconia Tab A100(7 inch display). However, they both use the layout declared in res/layout-large

As described here, starting from Android 3.2, the developer can declare layout based on the screen width, instead of using the now deprecated large, xlarge and other qualifiers. So I would declare a different layout for Acer Iconia Tab A100 in res/layout-sw600dp.

However, is there a way to achieve different layouts for the 2 devices if the tablet has Android 3.0 installed?

Alex Lockwood
  • 83,063
  • 39
  • 206
  • 250
Gabriel
  • 2,054
  • 4
  • 26
  • 34

2 Answers2

1

You could try to get the DeviceModel in code and load a layout depending on what device it is...

See http://developer.android.com/reference/android/os/Build.html#MODEL

Otherwise: whats the problem when both devices share the same layout?

Thkru
  • 4,218
  • 2
  • 18
  • 37
  • 1
    This will work if you want your app to work differently on two, specific device models. However, I think the OP was asking the more general question of how to deal with 5" and 7" inch tablets prior to SDK 13. – Alex Lockwood Jun 08 '12 at 16:06
1

Prior to Android 3.2, you could try to use screen density and resolution to derive the physical size and choose different resources (by name) based on that calculation at runtime. Accuracy would be difficult to guarantee, however, given the number of different sized tablets out there.

I would recommend you try to come up with a UI design that works OK on both 5" and 7" tablets.

Alex Lockwood
  • 83,063
  • 39
  • 206
  • 250
  • Thanks for the support. I was hoping there were a more developer-friendly solution to this problem, but it seems that there is no better way. – Gabriel Jun 11 '12 at 17:48
  • about getting the physical size, I have found this topic, for those who are facing the same problem: http://stackoverflow.com/questions/2193457/is-there-a-way-to-determine-android-physical-screen-height-in-cm-or-inches – Gabriel Jun 11 '12 at 17:50