Creating a Responsive Design - android

Hey guys I'm dealing with responsive design on Android with specifications below:
My app should not scroll.
I want to design it for all existing devices.
For now I opt for values/dimens file that I created for all dimension aspect in the app.
So I created w480dp, w300dp for widths and h750dp and h400dp for heights.
When I test my app in emulators:
320X480 Mdpi
480 x 854 Mdpi
480 x 800 Hdpi
768 x 1280 Xhdpi
They tooks all the w300dp X h400dp
In my testing device (galaxy S6 1440x2560) it took also w300dp X h400dp.
Anyone can tell me what qualifier should I use or even if I have a comprehension issue.

Related

Android spacing issue in same resolution devices 1080x1920

I am designing screen from Zeplin. (Zeplin provides each item attributes in dp)
Following is the horizontal recycler view design example with 4 items from Zeplin.
360 dp means 1080 for xxhdpi devices
I am testing my code on two 1080 devices with different dpi
Samsung c5 [1080 x 1920 pixels, 16:9 ratio (480dpi)]
Nexus 5X [1080 x 1920 pixels, 16:9 ratio (420dpi)]
I am facing spacing issue in Nexus-5x, the Zeplin design works great
on Samsung-c5.
Samsung-c5 result
Nexus-5x result - spacing issue in horizontal recycler view
QUESTION:
Why the design in different on same resolution (1080x1920) devices (different dpi). How can I make it look same on each and every device like facebook does with its status
Similar Questions:
How to use 1080x1920: 420 dpi - Android studio
Android xxhdpi, 420 dpi and 480 dpi
XXHDPI Layout different on different XXHDPI devices
Sol1 - Calculator app different layout on same screen size but different DPI (420 DPI vs 480 DPI) - Android Developer
Sol2 - Android layout folders for different screen sizes
Placing dimens in values-w410dp worked, as mentioned in the answer here

Resolution 768 x 1280

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").

Understanding dpi and the drawable folders

Yesterday I already asked a question about this here. After that I saw this on the official android developer page:
So you can have a 1024x600px screen device with ldpi and a screen with the same resolution with mdpi.
Furthermore you can have a 600x1024px screen device with mdpi and a screen with the same resolution with hdpi.
I have an image, that takes 20 % of the screen's height and width on every device.
I want to make 5 versions of that image (with different resolution) for each drawable folder.
In my past thread I got this answer:
ldpi: 0.75
mdpi: 1.0
hdpi: 1.5
xhdpi: 2.0
xxhdpi: 3.0
xxxhdpi: 4.0
These are the scale factors.
So if my image has a resolution of 50 x 100 px in mdpi it is supposed to have a resolution of 75 x 150 px in hdpi.
I understand that.
The question now is, how am I supposed to know what resolution my image should have in the mdpi folder, if the resolutions for mdpi are totally different (as you can see in the image above -> from 320x480 to 1280x768).
Thanks !
The drawables should be created at a resolution that makes them the right physical size when displayed on the screen. If you have an icon that is supposed to be 1/2 inch by 1/2 inch on an MDPI screen, then the image should be 80px by 80px. This size should be irregardless of the physical dimensions of the screen; the same drawable on a 1280x768 MDPI tablet is supposed to be 1/2 inch by 1/2inch.
If the icon in question should be larger on the tablet for some reason, then you would need to introduce the drawable-swXYZdp-mdpi folder that Der Golem mentioned above. In this folder, you would be able to create a version of the icon that had a larger physical size (say 3/4 inch) that will be loaded on the tablet.

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.
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.

android: Galaxy Note 2 : for which pixel layout images/icon should be prepared?

I am developing an app which must support Samsung Galaxy Note - 2.
Now note-2's pixel resolution is 1,280 x 720. Reference Wikipedia.
While developing an app, I found that it was picking images from res/drawable-hdpi.
So for what resolution layout I should prepare the images ? Or do need to make separate resource folder ?
Resources are picked based on DPI a quick reference for what DPI each device uses can be found here:
http://blog.blundell-apps.com/list-of-android-devices-with-pixel-density-buckets/
For image scaling, the images should roughly be sized like so:
if an image is to use 100 dp then the actual images sizes will be:
ldpi: 75px
mdpi: 100px
hdpi: 150px
xhdpi: 200px
if you want to use 100 px on your NOTE 2 then the image sizes will be
ldpi: 50px
mdpi: 66.67px
hdpi: 100px
xhdpi: 133.33px
you can use the following site do do quick calculations:
http://labs.skinkers.com/content/android_dp_px_calculator/
Prepare images for hdpi resolution -- 480x800 hdpi.
Galaxy Note 2 is normal size, xhdpi density and long. You can prepare layout or drawable for xhdpi. For details, please check this post Galaxy Note 2 screen specifications. If you don't have xhdpi resource, android will try to find resource in hdpi.
The Galaxy Note uses hdpi which is a pixel density of 240dpi
Android Device Resolutions

Categories

Resources