5

I have created an android application which works properly for nexus 7. Inside resources folder, I have created two folders, layout, layout-land for Nexus 7" tab. Everything was working fine till date. Now I want to create a different layout for Samsung Galaxy S3. For that, I have created a folders inside resources with layout-large & layout-large-land. But, here is the problem. Now, for Nexus 7 also, the layout defined in layout-large folder is getting loaded. How to stop that? How can I create different layout for Nexus 7" tab & Galaxy S3 mobile? I have read Supporting Multiple Screens documentation. But I couldn't understand as the screen size for Nexus 7 is 1204 X 800 & screen size for samsung galaxy S3 is 720 X 1280.

How to create different layouts for different devices with different screen resolutions & display sizes? Also, based on device size, I want to change few values in my application. How to do that one?

Manfred Moser
  • 29,539
  • 13
  • 92
  • 123
Bharath
  • 3,001
  • 6
  • 32
  • 65
  • 1
    Yes this is the main disadvantages of Android. Too many vendors doing their own sizes. You might want to have a look on my previous similar questions about multiple screens on http://stackoverflow.com/questions/11584107/how-to-deal-with-android-xlarge-screen or http://stackoverflow.com/questions/11008199/what-layout-is-suitable-for-720x1280-android-devices or http://stackoverflow.com/questions/10992764/how-android-manages-screen – stuckedunderflow Oct 10 '12 at 10:29

4 Answers4

10

According to the Supporting Multiple Screensenter image description here

Qualifiers like small, normal, large and xlarge is for Screen Sizes, which means Nexus 7 will use the resources with large qualifier, if you provide. Therefore before you create the folder with large qualifier, Nexus 7 will load the resources from default layout folder. As for ldpi, mdpi, hdpi and xhdpi is for the screen density.

To solve your problem, you need:

  1. put the layout definitions for Galaxy S3 into layout, and layout-sw600dp for Nexus 7. Please refer to Android Developers Blog: Getting Your App Ready for Jelly Bean and Nexus 7

  2. put the resources (images or drawable stuff) for Galaxy S3 into drawable-xhdpi, and drawable-tvdpi or drawable-hdpi for Nexus 7.

Hope it could help you, and please let me know if you have any other problems :)

Here are some useful references:

What layout is suitable for 720x1280 Android devices?

Screen Width Qualifier

Community
  • 1
  • 1
dumbfingers
  • 7,001
  • 5
  • 54
  • 80
  • Even after putting my layout definations for s3 in `layout`, `layout-large` is getting loaded – Bharath Oct 10 '12 at 12:04
  • Then please try put definitions for s3 in `layout`, and put those for Nexus in `layout-sw600dp` according to [Android Developers Blog](http://android-developers.blogspot.co.uk/2012/07/getting-your-app-ready-for-jelly-bean.html). Meanwhile I also updated my answer to include this comment. – dumbfingers Oct 10 '12 at 12:12
  • No. thats ok. It is working fine now when I have implemented your previous comment. Thats why I have deleted that comment. My mistake was, emulator configuration for s3 was not correct. thats why. Anyways, thanks for your effort. +25 – Bharath Oct 10 '12 at 13:19
  • Glad 2 hear that u've solved this. I've added more reference to my answer to help others. – dumbfingers Oct 10 '12 at 13:21
  • 1
    `layout-sw360dp` is a good option if you want a Galaxy S3 specific layout that's different from a default layout for smaller, more normally sized phones. `layout-sw600dp` is definitely what you want for the Nexus 7. – CorayThan Feb 28 '14 at 10:19
0

You need one for xlarge and xlarge-land aswell

Or you can do it programmatically by calling:

Display displayparm= activity.getWindowManager().getDefaultDisplay();
int width= displayparm.getWidth();
int Height= displayparm.getHeight();

and choosing layout from this info

  • @Andres.. I dint get you here. for which one should I use `xlarge`. I have created such layout. Even then `layout-large` is getting loaded for both S3 & Nexus 7 – Bharath Oct 10 '12 at 12:07
0

you could create the layout by adding new folder under the res folder as layout-xlarge and layout-xlarge-large and u have to update the android manifest file as well to support the for higher resolution

0

I have developed an application where i support multiple devices with different resolution and densities. with nexus 7 and galaxy s3 also one among them. galaxy s3 and nexus7 will obviously take from the large screen folder if u have layout-large folder in your project. But galaxy s3 falls under large hdpi category and nexus7 falls under large-tvdpi category. so it will be of great use if you have layout-large-hdpi and layout-large-tvdpi for s3 and nexus7 respectively.

khubaib
  • 535
  • 4
  • 12