Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create different layout for Galaxy S3 and Nexus 7?

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?

like image 932
Bharath Avatar asked Oct 10 '12 09:10

Bharath


1 Answers

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

like image 64
dumbfingers Avatar answered Oct 22 '22 04:10

dumbfingers