user2369472
user2369472

Reputation: 21

How to create different layout for Galaxy S4 and Nexus 4

I am using "layout-sw360dp" for both Galaxy S4 and Nexus 4 devices but in my screen displaying some space on Galaxy S4. so can i make different layout for both Galaxy S4 and Nexus 4. if it is possible then please give me the solution.

Upvotes: 0

Views: 10625

Answers (5)

DebraD
DebraD

Reputation: 87

ok here goes... for reference

  1. this is older layout folder naming conventions but you get the point.

  2. You must convert everything to mdpi to go into the following buckets.

  3. buckets for layouts are : xlarge 960 x720 min large 640 x480 min normal 470 x 320 min small 426x 320 min

  4. scaling ratio 3:4:6:8:12 this means that you must multiple ldpi * 3/4 to go from ldpi to mdpi and you must multiple mdpi * 4/6 to go from mdpi to hdpi and you must multiple hdpi * 6/8 to go from hdpi to xhdpi and you must multiple xhdpi * 8/12 to go from xhdpi to xxhdpi

so to answer the question....

s4 is xxhdpi which means the scaling ratio is 4/12 or 1/3. This means that you have to convert from xxhdpi to mdpi to place in a layout folder properly.
so 1080 * 1/3 = 360 and 1920 * 1/3 = 640 so this would place it in a normal layout folder

nexus 4 is xhdpi which means the scaling ratio is 4/8 or 1/2. 4 This means that you have to convert from xhdpi to mdpi to place in a layout folder properly. so 1280 * 1/2 = 640 and 768 * 1/2 = 384 so this would place it in a normal layout folder as well.

ok, so this doesn't quite cut it because they are different resolutions. we can make up folders with the new naming conventions. for example the smallest width for the s4 is 360 while the smallest width for the nexus 4 is 384. so folders could be sw360dp and sw384dp.
you could also name the folder layout-xxhdpi which would catch the s4 but not the nexus 4

be aware: Just to throw another one out there what if you had an s3 as well. that would go in the sw360dp folder as well. so I guess you would have to differ between them as well. if you used layout-xxhdpi above then you could use sw360dp here and sw384dp above as well. cover them all. thanks

Upvotes: 5

Sagar Maiyad
Sagar Maiyad

Reputation: 12753

for nexus 4 use below layout.

layout-sw360dp

both galaxy s3 and nexus 4 have same layouts.

Upvotes: 0

MaciejGórski
MaciejGórski

Reputation: 22232

As per other answers one device is 640 x 360 dp and the other 640 x 384 dp.

You don't want to make a different layout for them, because you will sooner or later see a device 640 x 372 dp or 640 x 388 dp.

Instead make your layout elastic and don't hardcode pixels (density independent pixels can also be badly hardcoded).

Upvotes: 7

Renjith
Renjith

Reputation: 5803

For Galaxy s4 use layout-xxhdpi

For Nexus 4 use layout-xhdpi

Galaxy S4 -- 1080 x 1920 pixels -- 5.0" -- 441 ppi -- xxhdpi
Nexus 4   -- 1280 x  768 pixels -- 4.7" -- 320 ppi -- xhdpi

You have to make different images to fit to the resolution of these devices

Upvotes: 8

Anukool
Anukool

Reputation: 5391

Both these phones have different screen size and resolution ,
that leads to different density as well .

As per my knowledge -

Galaxy s4 has 1080 x 1920 pixels, 5.0 inches (~441 ppi pixel density).

And

Nexus 4 has 1280 x 768 pixels, 4.7 inches (320 ppi ).

You will have to design the layouts (and images as well ) according to the phones specifications.

Upvotes: 0

Related Questions