ChatGPT解决这个技术问题 Extra ChatGPT

Image resolution for mdpi, hdpi, xhdpi and xxhdpi

I have a background for my app in resolutions 720x1280 pixels, 1080x1920 pixels and 1440x2560 pixels.

In which folders (mdpi, hdpi, xhdpi and xxhdpi) should I put each background?

You're confusing resolution and density.

R
Rjz Satvara

Please read the Android Documentation regarding screen sizes.

From a base image size, there is a 3:4:6:8:12:16 scaling ratio in drawable size by DPI.

LDPI - 0.75x
MDPI - Original size // means 1.0x here 
HDPI - 1.5x
XHDPI - 2.0x
XXHDPI - 3x
XXXHDPI - 4.0x

For example, 100x100px image on a MDPI will be the same size of a 200x200px on a XHDPI screen.


so if I get this straight, the DP is calculated dividing a 160 DPI screen (which is the mdpi base) and the screen DPI, which gives the factors of 0.75, 1,1.5, 2, 3 and 4 and those are used to scale the resolution of the desired image right? Sorry, this is a bit confusing yet
Is this also true for text size?
Somewhat I'm not agree with your answer because if your original image size is 1500x1500 then XXXHDPI should be 6000x6000 and it will cause out of memory error, can you elaborate more on it. what is a standard size for the dpi so we can follow this one.
R
Rytis

Require Screen sizes for splash :

LDPI: Portrait: 200 X 320px
MDPI: Portrait: 320 X 480px
HDPI: Portrait: 480 X 800px
XHDPI: Portrait: 720 X 1280px
XXHDPI: Portrait: 960 X 1600px
XXXHDPI: Portrait: 1440 x 2560px

Require icon Sizes for App :

http://iconhandbook.co.uk/reference/chart/android/


Why is xxxhdpi x size larger than y? Why 320*4 equals to 1440 and 320*2 equals to 720? Please, edit.
Thanks. For all those ppl who want to know the max resolution you can use for the screen size refer this.
S
Saeed

DP size of any device is (actual resolution / density conversion factor).

Density conversion factor for density buckets are as follows:

ldpi: 0.75
mdpi: 1.0 (base density)
hdpi: 1.5
xhdpi: 2.0
xxhdpi: 3.0
xxxhdpi: 4.0

Examples of resolution/density conversion to DP:

ldpi device of 240 X 320 px will be of 320 X 426.66 DP. 240 / 0.75 = 320 dp 320 / 0.75 = 426.66 dp xxhdpi device of 1080 x 1920 pixels (Samsung S4, S5) will be of 360 X 640 dp. 1080 / 3 = 360 dp 1920 / 3 = 640 dp

This image show more:

https://i.stack.imgur.com/OEeFj.png

For more details about DIP read here.


T
Tin Luu

Your inputs lack one important information of device dimension. Suppose now popular phone is 6 inch(the diagonal of the display), you will have following results

https://i.stack.imgur.com/cUM9F.png

DPI: Dots per inch - number of dots(pixels) per segment(line) of 1 inch. DPI=Diagonal/Device size

Scaling Ratio= Real DPI/160. 160 is basic density (MHDPI)

DP: (Density-independent Pixel)=1/160 inch, think of it as a measurement unit


l
ldev

https://i.stack.imgur.com/jYrQk.png

Check the image above I hope it will help someone.

Link to the whole article itself


c
change_is_necessity

in order to know the phone resolution simply create a image with label mdpi, hdpi, xhdpi and xxhdpi. put these images in respective folder like mdpi, hdpi, xhdpi and xxhdpi. create a image view in layout and load this image. the phone will load the respective image from a specific folder. by this you will get the phone resolution or *dpi it is using.


... or do the same with string resources, which might be a bit easier to handle. Good idea though as you can add more info and compose a handy utility app that shows you some device properties.