Anand Asir
Anand Asir

Reputation: 309

Android Resources called from Different layout folders

I am having two android devices which are having the same resolution and PPI. But when i run my application for one device that is Samsung Tab 4, the resources are called from normal layout folder. But for another device that is Samsung J Max, it is from layout-600 folder. Why this is behaving differently for these devices? Any suggestions would be greatly appreciated.

Upvotes: 1

Views: 366

Answers (3)

Kingfisher Phuoc
Kingfisher Phuoc

Reputation: 8210

You should check This Google Article. It pointed out that:

In this context, the Samsung has another little surprise: If you do the arithmetic, its screen has 170 DPI, which is far from the densest among Android devices. Still, it declares itself as “hdpi” (and as having a “large” screen size). The reason is simple: It looks better that way.

That means your Tab ppi is 170 (not 220ppi). As a result: 800 width, 170 ppi --> 800/(170/160) > 600. That's why your Samsung Tab 4 resource is from folder "layout-sw600dp"

Upvotes: 1

Kapil Rajput
Kapil Rajput

Reputation: 11565

This depends on Density Pixels(dp) of Android Devices which very from device to device and according to that Android device detect automatically from which layout folder it will show the UI, here is the little information how it works :

As you design your UI for different screen sizes, you'll discover that each design requires a minimum amount of space. So, each generalized screen size above has an associated minimum resolution that's defined by the system. These minimum sizes are in "dp" units—the same units you should use when defining your layouts—which allows the system to avoid worrying about changes in screen density.

xlarge screens are at least 960dp x 720dp

large screens are at least 640dp x 480dp

normal screens are at least 470dp x 320dp

small screens are at least 426dp x 320dp

A set of six generalized densities:

ldpi (low) ~120dpi

mdpi (medium) ~160dpi

hdpi (high) ~240dpi

xhdpi (extra-high) ~320dpi

xxhdpi (extra-extra-high) ~480dpi

xxxhdpi (extra-extra-extra-high) ~640dpi

For more info please read google doc :https://developer.android.com/guide/practices/screens_support.html

Upvotes: 0

Mike Laren
Mike Laren

Reputation: 8188

The 600 qualifier in layout-600 has to do with the screen dimensions in dp and not necessarily with the DPI or the screen resolution in pixels. Other factors like the aspect ratio and the diagonal size of the screen are also taken into consideration.

You can determine the dimensions of your screen in dp programmatically using the instructions in this post:

Configuration configuration = yourActivity.getResources().getConfiguration();
int screenWidthDp = configuration.screenWidthDp; //The current width of the available screen space, in dp units, corresponding to screen width resource qualifier.

I bet that the value of screenWidthDp is different between those devices.

Upvotes: 0

Related Questions