18

I am developing an application for google nexus 7 and 10. But there is a problem. I don't know which layout folder should be used for 7 and 10.

MysticMagicϡ
  • 28,593
  • 16
  • 73
  • 124
User42590
  • 2,473
  • 12
  • 44
  • 85

6 Answers6

18

For nexus 7

layout-large-hdpi

For nexus 10

layout-xlarge-xhdpi

Note: The app takes images from these folders only if you have not given higher precedence qualifiers. For example if you have given a layout folder like layout-sw360dp the app will take only the images from this folder even if you have given separate layouts like the one I said above. Because in android there is an order of precedence in which you have to give layouts.

Check this official doc for the order of precedence of qualifiers.

EDIT: Providing layouts for Tablets is a very confusing thing in Android. I had a horrible time in providing layouts for tablets. However I finally succeeded after so many attempts. Having said that one thing you have to remember is that, even if you have not given the right folder, Android will take the next suitable layout folder with respect to the device.

Now regarding your comment, for samsung 7, I think the ideal layout will be

layout-large-mdpi.

And for samsung 7.7, it may be

layout-large-hdpi (which I haven't tried yet)

And for Samsung 10.1, it will be

layout-xlarge-mdpi

Regarding your Nexus 10, you have to make separate images to fit to its size.

Renjith
  • 5,783
  • 9
  • 31
  • 42
  • i am new to android and so much confuse about layouts. Please can you clarify that layout-large-hdpi folder also used for Samsung 7.7 and layout-xlarge/xhdpi for Samsung 10.1. So how can the device pick the right folder. Actually i want that my apk should contains all layouts. I don't want to make separate apks for different devices. – User42590 Jan 28 '13 at 07:05
  • And galaxy nexus 10 uses resolution of 2560x1600 so i have to make separate images of this size? – User42590 Jan 28 '13 at 07:07
  • thank you for the next suggestion but layout-large-mdpi is used for samsung 7 inch tab device. 7.7 samsung uses layout-large-hdpi this makes me so confuse – User42590 Jan 28 '13 at 07:18
  • because layout-large-hdpi is also used for galaxy nexus 7. and if we give the right qualifier like layout-large-hdpi-1280x800 which used for samsung 7.7 . And galaxy nexus 7 is also 1280x800 in resolution so how can we make difference between these two?? – User42590 Jan 28 '13 at 07:25
  • now you make me clear about galaxy nexus 10.1 but i am still confused about galaxy nexus 7 – User42590 Jan 28 '13 at 07:30
  • Nexus 7 have a `dpi` of 213. That's the difference between normal `1280 * 800` devices. – Renjith Jan 28 '13 at 07:48
  • @Akhter A correction: I misread samsung 7.7 with samsung 7. So for samsung 7.7, `layout-large-hdpi` may be the correct folder. You have to make sure that. – Renjith Jan 28 '13 at 07:52
  • so what will be the exact folder names for samsung 7.7 and galaxy nexus 7?? – User42590 Jan 28 '13 at 07:52
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/23482/discussion-between-akhter-and-rkn) – User42590 Jan 28 '13 at 07:53
  • Google nexus 7 is not layout-large-hdpi, it should be tvdpi – Frank Nguyen Dec 26 '13 at 04:17
  • Which layout folders i need to create for Nexus 9 and Nexus 10 devices? – Dhaval Khant Jun 15 '15 at 10:26
  • @DhavalKhant You have to make use of **layout-sw??>dp** to differentiate between Nexus 9 and Nexus 10 as both has the same density. i.e **layout-xlarge-xhdpi**. In terms of dp, Nexus 9 is **layout-sw768dp** and Nexus 10 is **layout-sw800dp**. – Renjith Jun 16 '15 at 03:30
16

According to http://android-developers.blogspot.com/2012/07/getting-your-app-ready-for-jelly-bean.html

Nexus 7 (2012) should be tvdpi

Then, in my opinion

For Nexus 7 (2012)

  • Layout file in layout-sw600dp-land, layout-sw600dp-port

  • Image resources in drawable-sw600dp-tvdpi

For Nexus 10

  • Layout file in layout-sw720dp-land, layout-sw720dp-port

  • Image resources in drawable-sw720dp-xhdpi (1600x2560)

Frank Nguyen
  • 6,493
  • 3
  • 38
  • 37
  • +1 now I know my emulator wasn't acting weird. Could you tell or refer me resource which I states which drawable folders for what resolutions? Will be very thankful. :) – Sufian Sep 19 '14 at 06:37
  • Thanks. I have read that page before. The problem was that I had folders `drawable-sw720dp` and `drawable-sw600dp` and was hoping Nexus 7 would still use `drawable-large-xhdpi` instead. I had to remove those folders so that Nexus would use correct images. For anyone else, also read this answer http://stackoverflow.com/a/16910589/1276636 – Sufian Sep 22 '14 at 05:04
  • You should try drawable-large-tvdpi. But in my opinion, you should not use -large or -xlarge and change to -sw... – Frank Nguyen Sep 22 '14 at 11:55
  • Oh yes, I used the `drawable-large-tvdpi`, forgot to mention the correct one here. the `sw` is tricky because I found that if a device has 600dp or greater, it will use that drawable folder, so if your drawables are designed to take up all of the width, images might get blurry by getting squished. It might be a cool feature in other cases though. – Sufian Sep 22 '14 at 12:08
11

Since android 3.2 you should use layout-sw600dp for the 7" tablet and layout-720dp for the 10". If you want to keep backwards compatibility with older version of android (pre 3.2, you should also use the old layout-xlarge* notation

Blackbelt
  • 156,034
  • 29
  • 297
  • 305
  • I've really found that the post API 13 way to do this is to make sure that all the devices are supported is to use layout-sw600dp-land-tvdpi for the Nexus 7. If anyone has a Nexus 10 device, test layout-sw720dp-land-xhdpi to see if that works? Thanks @blackbelt – whyoz Apr 10 '13 at 17:04
  • "you SHOULD use" not "HAVE to use" – Ovidiu Latcu Jul 09 '13 at 07:12
  • @Ankit any specific reasons why nexus 10 is not taking **layout-sw720dp** ?? we have to add -land-xhdpi ! – LOG_TAG Mar 14 '14 at 06:39
  • If you have only that folder in your project it will take from layout-sw720dp only but every thing will be scale down because it's resolution is high. If you want a specific layout for nexus 10 and different for other devices then only you should use layout-sw720dp-land-xhdpi – Ankit Mar 14 '14 at 11:40
6

To add to @blackbelt, I was testing on my Nexus 7 and on a 600x1024mdpi emulator and found that the two will be considerably off.

The quick way to fix this would be to create the layout folders:

layout-sw600dp-land-tvdpi

layout-sw600dp-port-tvdpi

This has been tested and verified to work for the Nexus 7 specifically since the tvdpi density is rare.

So the layout folders:

layout-sw600dp-land

layout-sw600dp-port

would then be for devices with a mdpi density. There are way more devices that fall into the second category, so you really shouldn't rely on using the naming convention without tvdpi to support the Nexus 7.

This obviously can apply to the Galaxy Note and other devices that are hdpi and so on.

whyoz
  • 5,168
  • 47
  • 53
2

You can now use the Google Design "device metrics" website. It has a lot of devices listed.

Link: https://design.google.com/devices/

milosmns
  • 3,595
  • 4
  • 36
  • 48
1

For nexus 10 you can put your layout in layout-sw720dp-land-xhdpi folder.

Ankit
  • 1,916
  • 2
  • 20
  • 33