Answer the question
In order to leave comments, you need to log in
Android: Why isn't values-sw320dp folder used with ldpi?
As I understand it, swdp is calculated as follows: the smallest side is taken and divided by the dpi of the screen. I tried to run it on an ldpi emulator with a density of 240*320 pixels. If I'm right, then the smallestWidth for this emulator is 240px/0.75 = 320dp. But for some reason, the values are taken from the values-sw240dp folder, and not values-sw320dp. The help says:
Some values you might use here for common screen sizes:
320, for devices with screen configurations such as:
-240x320 ldpi (QVGA handset)
-320x480 mdpi (handset)
-480x800 hdpi (high density handset)
and I don't understand why 240*320 pixels , ldpi device doesn't take the required values from the correct folder. Android 4.0. By the way, mdpi, hdpi, xhdpi with other resolutions work fine - it calculates dp as expected.
Answer the question
In order to leave comments, you need to log in
In fact, I would not rely on emulators in such subtle matters. After all, it can scale on the computer screen, and it can simply work "a little wrong".
Although I don’t have a similar device with Android 3.2+ and such a display (do they even exist? o_O), we can assume that ldpi is ~ 120dpi, i.e., as far as I understand, it can be a little more and a little less. Moreover, if it is limited to 120 + (160 - 120) / 2 = 140dpi from above, then nothing can be said for sure from below. Correct me if wrong.
Well, actually, try to output somewhere:
DisplayMetrics metrics = getResources().getDisplayMetrics();
metrics.densityDpi - it will be equal to one of the constants referred to as DENSITY_(number).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question