sw600dp quantifier not working on Galaxy Tab
Asked Answered
F

2

22

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?

Falkirk answered 19/1, 2012 at 12:49 Comment(2)
Worth asking, but is your Galaxy Tab on Android 3.2? These identifiers were only introduced in 3.2.Morale
No 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.Falkirk
M
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.

Morale answered 20/1, 2012 at 1:27 Comment(5)
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?Falkirk
I 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 (android-developers.blogspot.com/2011/07/…) 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-landMorale
Oh! I have already read this article but not the end of it. Thank you.Falkirk
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.0Falkirk
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. <?xml version="1.0" encoding="utf-8"?> <resources> <item type="layout" name="main_activty"> @layout/main_activity_tablet </item> </resources>Morale
B
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

Begun answered 16/7, 2012 at 13:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.