ChatGPT解决这个技术问题 Extra ChatGPT

Android: Background Image Size (in Pixel) which Support All Devices

I am creating an Application which will run on all Android Devices. I want to create xhdpi Graphics for My App. My App is full screen. I am confused in Creating graphics. can any one tell me the best sizes of my background image in pixels.

For Example:

xhdpi: 720x1280 px

hdpi: 480x800 px

mdpi: 320x480 px

ldpi: 240x320 px

Suggest me the best sizes which will appear on all devices good. Because my graphics are the core of my app.

I want that every device get the best image which it want. Android will be not involved in compressing or expanding of image.

Read Android Documentation's Android Multiple screen support, they give the standard for User interface
Use this one solution this the best for all old and new and for upcoming devices. stackoverflow.com/a/40255870/2489061

C
Community

The following are the best dimensions for the app to run in all devices. For understanding multiple supporting screens you have to read http://developer.android.com/guide/practices/screens_support.html

xxxhdpi: 1280x1920 px
xxhdpi: 960x1600 px
xhdpi: 640x960 px
hdpi: 480x800 px
mdpi: 320x480 px
ldpi: 240x320 px

interesting, nexus 5 is xxhdpi, but it screen size is 1080x1920
The LG G3 has a resolution of 1440 x 2560 and uses xxxhdpi.
Thats the main problem/challenge with android, there is no set size for hdpi, xhdpi, etc. because each manufacture can make a different sized phone/tablet, unlike IOS where only apple makes it. Look at section on range: developer.android.com/guide/practices/…
Use this one solution this the best for all old and new and for upcoming devices. stackoverflow.com/a/40255870/2489061
what about dpi?
C
Community

Android Devices Matrices

                            ldpi     mdpi     hdpi    xhdpi    xxhdpi      xxxhdpi
Launcher And Home           36*36    48*48   72*72    96*96    144*144     192*192
Toolbar And Tab             24*24    32*32   48*48    64*64    96*96       128*128
Notification                18*18    24*24   36*36    48*48    72*72       96*96 
Background                 240*320  320*480 480*800  768*1280  1080 *1920  1440*2560 

(For good approach minus Toolbar Size From total height of Background Screen and then Design Graphics of Screens )

For More Help (This link includes tablets also):

https://design.google.com/devices/

Android Native Icons (Recommended) You can change color of these icons programmatically. https://design.google.com/icons/


Why don't theses align with the multipliers suggested here? developer.android.com/training/multiscreen/screendensities#java
K
Ketan Ramani

Check this. This image will show for all icon size for different screen sizes

https://i.stack.imgur.com/JxzS6.jpg


wheres this from?
from one of the site while surfing
C
Community

I looked around the internet for correct dimensions for these densities for square images, but couldn't find anything reliable.

If it's any consolation, referring to Veerababu Medisetti's answer I used these dimensions for SQUARES :)

xxxhdpi: 1280x1280 px
xxhdpi: 960x960 px
xhdpi: 640x640 px
hdpi: 480x480 px
mdpi: 320x320 px
ldpi: 240x240 px

Use this one solution this the best for all old and new and for upcoming devices. stackoverflow.com/a/40255870/2489061
S
Sagar Rathod

GIMP tool is exactly what you need to create the images for different pixel resolution devices.

Follow these steps:

Open the existing image in GIMP tool. Go to "Image" menu, and select "Scale Image..." Use below pixel dimension that you need: xxxhdpi: 1280x1920 px xxhdpi: 960x1600 px xhdpi: 640x960 px hdpi: 480x800 px mdpi: 320x480 px ldpi: 240x320 px Then "Export" the image from "File" menu.


O
Overclover

My understanding is that if you use a View object (as supposed to eg. android:windowBackground) Android will automatically scale your image to the correct size. The problem is that too much scaling can result in artifacts (both during up and down scaling) and blurring. Due to various resolutions and aspects ratios on the market, it's impossible to create "perfect" fits for every screen, but you can do your best to make sure only a little bit of scaling has to be done, and thus mitigate the unwanted side effects. So what I would do is:

Keep to the 3:4:6:8:12:16 scaling ratio between the six generalized densities (ldpi, mdpi, hdpi, etc).

You should not include xxxhdpi elements for your UI elements, this resolution is meant for upscaling launcher icons only (so mipmap folder only) ... You should not use the xxxhdpi qualifier for UI elements other than the launcher icon. ... although eg. on the Samsung edge 7 calling getDisplayMetrics().density returns 4 (xxxhdpi), so perhaps this info is outdated.

Then look at the new phone models on the market, and find the representative ones. Assumming the new google pixel is a good representation of an android phone: It has a 1080 x 1920 resolution at 441 dpi, and a screen size of 4.4 x 2.5 inches. Then from the the android developer docs: ldpi (low) ~120dpi mdpi (medium) ~160dpi hdpi (high) ~240dpi xhdpi (extra-high) ~320dpi xxhdpi (extra-extra-high) ~480dpi xxxhdpi (extra-extra-extra-high) ~640dpi This corresponds to an xxhdpi screen. From here I could scale these 1080 x 1920 down by the (3:4:6:8:12) ratios above.

ldpi (low) ~120dpi

mdpi (medium) ~160dpi

hdpi (high) ~240dpi

xhdpi (extra-high) ~320dpi

xxhdpi (extra-extra-high) ~480dpi

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

I could also acknowledge that downsampling is generally an easy way to scale and thus I might want slightly oversized bitmaps bundled in my apk (Note: higher memory consumption). Once more assuming that the width and height of the pixel screen is represetative, I would scale up the 1080x1920 by a factor of 480/441, leaving my maximum resolution background image at approx. 1200x2100, which should then be scaled by the 3:4:6:8:12.

Remember, you only need to provide density-specific drawables for bitmap files (.png, .jpg, or .gif) and Nine-Patch files (.9.png). If you use XML files to define drawable resources (eg. shapes), just put one copy in the default drawable directory.

If you ever have to accomodate really large or odd aspect ratios, create specific folders for these as well, using the flags for this, eg. sw, long, large, etc.

And no need to draw the background twice. Therefore set a style with @null


I am using xml files to show the images in the android. So which pixels are preferable 1080p ?