I have a program with 2 fragments. On tablets I am showing both of them.
I am doing this with /layout-sw600dp
folder.
On Motorola Xoom and other tablets it is working but not in Samsung Galaxy Tab 10.1
This is very strange. I have searched everywhere and havent come accross with a person with the same problem?
What can be the reason?
Asked
Active
Viewed 8,638 times
22

tasomaniac
- 10,234
- 6
- 52
- 84
-
Worth asking, but is your Galaxy Tab on Android 3.2? These identifiers were only introduced in 3.2. – Alex Curran Jan 19 '12 at 17:27
-
1No it is on Android 3.1? This could be the problem. But how am I supposed to identify tablets. If I simply use /layout-v11, it also includes ICS phones. How can I support both ICS phones, Gingerbread phones and all 3.1, 3.2 and ICS tablets. – tasomaniac Jan 19 '12 at 22:18
2 Answers
32
Might as well put this as an answer. The swXXXdp identifiers are only for Android 3.2 and above. If you want to make sure you properly target tablets both post- and pre-3.2, you must use the swXXXdp attribute and large/xlarge attributes. So for an example:
- /layout/ -- for phone devices and portrait tablets
- /layout-xlarge-land/ for landscape tablets pre-3.2
- /layout-sw600dp-land/ for landscape tablets post-3.2
Before Honeycomb 3.2, Android used "size buckets" of small (e.g. Wildfire), normal (basically any phone), large (Streak 5, OG Galaxy Tab), xlarge (Xoom), but now ditches them in favour of these dp values which allow finer control.

Alex Curran
- 8,818
- 6
- 49
- 55
-
I want a tablet layout also in OG Galaxy Tab. Do I need to just put them /layout-large-land/? If I do this, xlarge tablets will also get this layout right? – tasomaniac Jan 21 '12 at 09:41
-
1I think you can just put them in large-land, yes, but I don't know whether this will also be used for xlarge-land as well. This blog post (http://android-developers.blogspot.com/2011/07/new-tools-for-managing-screen-sizes.html) has some good tips for managing multiple configurations using the same resource file, so you could use the "linking" files described at the bottom of the post in large-land, xlarge-land and sw600dp-land – Alex Curran Jan 23 '12 at 00:01
-
Oh! I have already read this article but not the end of it. Thank you. – tasomaniac Jan 23 '12 at 12:57
-
But at the end it uses config.smallestScreenWidthDp which is introduced in API level 13. What is the difference anyway? config.smallestScreenWidthDp wont work on Android 3.1 or 3.0 – tasomaniac Jan 23 '12 at 13:13
-
I'd use the bit above it, where it defines them in the layouts themselves. So, for example, the main_activity.xml file in large-land, xlarge-land and sw600dp-land would be as below. You could determine which to use in code as in the last part of the article but you'd need to use reflection and that's a more complex approach. `
- @layout/main_activity_tablet
1
If you need support for 7 inch tables, then it is not xlarge but large: /layout/ -- for phone devices and portrait tablets /layout-large-land/ for landscape tablets pre-3.2 /layout-sw600dp-land/ for landscape tablets post-3.2

TommyV
- 11
- 1