I have 2 different android phones. The details are
nexus s: 480 x 800 pixels, 4.0 inches (~233 ppi pixel density)
desire s: 480 x 800 pixels, 3.70 inches (~252 ppi pixel density)
Now I have my layout folders as layout_hdpi and layout_xhdpi. Now both these phones are classes as hdpi phones. I have a controls with a padding of 5dip to the left and the right. But on these phones the 5dip translates to different widths hence the border on one phone is fatter then on the second phone. Increasing one also increases the other. Can someone help me please?
for different screen sizes use relative-layouts.. it will not cause the problem of different width on different phones
First of all layout_hdpi and layout_xhdpi should be declared as layout-hdpi and layout-xhdpi.
Secondly, HDPI refers to the range 161–240(ppi). So your Nexus phone is eligible for the HDPI qualifier, but your Desire S is eligible for XHDPI qualifier, because the range of xhdpi is 241–319.
Related
I have an app in the play store which runs on all mobiles and now I want to release it on tablets as well.
1) The images have been designed for xhdpi screens. So I think that will be sufficient to support tablets as well or should I redesign the images seperately for tablets?
2) I want to split dimens.xml into 3 categories -
dimens.xml for all mobile phones
dimens.xml for all 7 inch tablets
dimens.xml for all 10 inch tablets
The solution I came up with is divide the values folder like below -
values/dimens.xml
values-sw620dp/dimens.xml
values-sw720dp/dimens.xml
but since few mobile phones might fall into values-sw620dp/dimens.xml or values-sw720dp/dimens.xml, What is the appropriate way to divide dimens.xml into 3 categories??
Please do not post the below picture as I want to divide into 3 categories
Following is Struture Answered by Many
1) There is no tablet device in the market with higher density than xhdpi. Therefore, xhdpi images are sufficient to support tablets
2) Dividing the values folder as below will be helpful
- values\dimens.xml
- values-land\dimens.xml
- values-sw600dp\dimens.xml
- values-sw600dp-land\dimens.xml
- values-sw720dp\dimens.xml
- values-sw720dp-land\dimens.xml
The suffix -land is used for lanscape orientation.
Mobile phones do not fall into the sw600dp or sw720dp category. I think you are confused between dp and px.
Example:
Take Samsung Galaxy S7 Edge.
Resolution : 1440 x 2560px
Density : xxxhdpi
Converting 1440px to dp at xxxhdpi density, you get 320dp (Convert px to dp)
Therfore the width of Samsung Galaxy S7 edge in dp is 320dp and will fall in values\dimens.xml file
If you take a Tab and find dp similarly, you will notice that the dp will be greater than or equal to 600dp.
Is it possible to make a layout for this nexus 4 resolution . my app give problem with custom views.
i have
layout-hdpi
layout-xhdpi
layout-xxhdpi
i know xhdpi includes 768 x 1280 and 720 x 1280 .
dpi only partially depends on resolution. It is a measure of how tightly the pixels are packed on the screen. Thus, it is a function of both resolution, as well as the physical size of the screen.
Saying 768 x 1280 px = xhdpi may be correct for some devices, but incorrect for others. For example, what if you have a 10 inch screen that has that resolution? That would most likely be ldpi.
In order to support multiple screens, please follow this guide: http://developer.android.com/guide/practices/screens_support.html
You may want to use dp's instead of pixels in your layouts for setting widths and heights. You can then customize layouts based on the current width of the device by using layout directories such as layout-sw320dp ("smallest width 320 dp").
I'm developing an Android Widget and need to differentiate between Galaxy S and Galaxy S2.
I almost read everything about Screen sizes and densities articles.
And I need, of course, to use the new qualifiers with the new qualifier Smallest Width.
My problem is, that the sw320dp qualifier match for Galaxy S and also for Galaxy S2.
But I need another layout for Galaxy S2, but cant find the right qualifier for it.
Definition of Galaxy S, Density 233
Screen Size in Pixels: 480 Pixel x 800 Pixel
Screen Size in dp: 329dp x 549dp (cause 1dp = 1pixel/(density/160)
-> so the qualifier sw320dp must match here. and yes it does
Definition of Galaxy S II, Density 218
Screen Size in Pixels: 480 Pixel x 800 Pixel
Screen Size in dp: 352dp x 587dp (cause 1dp = 1pixel/(density/160)
-> so the qualifier sw340dp must match here, but NO it doesnt
(Tested in emulator and on real device)
The drawables are not the problem, but my layout, especially the height and text sizes are different on these devices, so I really need a specific layout for them.
Anyone has an idea or more experience with it?
Screen density, as defined by the reference material is:
The quantity of pixels within a physical area of the screen; usually referred to as dpi (dots per inch). For example, a "low" density screen has fewer pixels within a given physical area, compared to a "normal" or "high" density screen.
For simplicity, Android groups all actual screen densities into four generalized densities: low, medium, high, and extra high.
low = 120dpi
med = 160dpi
high = 240dpi
xhi = 320dpi
So the Galaxy SII, with a real density of 218, gets assigned a "high" density of 240 in dp calculations. Thus the width of the screen in dp is 480/240*160 = 320.
This sucks, I agree. But it's how it works.
http://developer.android.com/guide/practices/screens_support.html
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.
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
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).
ok here goes...
for reference
this is older layout folder naming conventions but you get the point.
You must convert everything to mdpi to go into the following buckets.
buckets for layouts are :
xlarge 960 x720 min
large 640 x480 min
normal 470 x 320 min
small 426x 320 min
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
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.
for nexus 4 use below layout.
layout-sw360dp
both galaxy s3 and nexus 4 have same layouts.
I'm developing an Android Widget and need to differentiate between Galaxy S and Galaxy S2.
I almost read everything about Screen sizes and densities articles.
And I need, of course, to use the new qualifiers with the new qualifier Smallest Width.
My problem is, that the sw320dp qualifier match for Galaxy S and also for Galaxy S2.
But I need another layout for Galaxy S2, but cant find the right qualifier for it.
Definition of Galaxy S, Density 233
Screen Size in Pixels: 480 Pixel x 800 Pixel
Screen Size in dp: 329dp x 549dp (cause 1dp = 1pixel/(density/160)
-> so the qualifier sw320dp must match here. and yes it does
Definition of Galaxy S II, Density 218
Screen Size in Pixels: 480 Pixel x 800 Pixel
Screen Size in dp: 352dp x 587dp (cause 1dp = 1pixel/(density/160)
-> so the qualifier sw340dp must match here, but NO it doesnt
(Tested in emulator and on real device)
The drawables are not the problem, but my layout, especially the height and text sizes are different on these devices, so I really need a specific layout for them.
Anyone has an idea or more experience with it?
Screen density, as defined by the reference material is:
The quantity of pixels within a physical area of the screen; usually referred to as dpi (dots per inch). For example, a "low" density screen has fewer pixels within a given physical area, compared to a "normal" or "high" density screen.
For simplicity, Android groups all actual screen densities into four generalized densities: low, medium, high, and extra high.
low = 120dpi
med = 160dpi
high = 240dpi
xhi = 320dpi
So the Galaxy SII, with a real density of 218, gets assigned a "high" density of 240 in dp calculations. Thus the width of the screen in dp is 480/240*160 = 320.
This sucks, I agree. But it's how it works.
http://developer.android.com/guide/practices/screens_support.html