Image size for all screen devices
Asked Answered
P

4

15

I have PSD, resolution of that is 1080X1920, it contains a Dot image whose resolution is 22X22.

I have cropped that image and put it in my res folder.

My question is how would Android know that the image is for 1080X1920 screen. It would open the same image bigger in small screen and smaller in 2560x1440 resolution.

Is there a way other than putting different images for each screen sizes to tell android to use the image for specific screen size and scale for other screens

Postboy answered 13/5, 2016 at 10:19 Comment(2)
You can manage Height and Width of image using dimen.xml by passing different dimen to each values folder.Insolvable
You can use this tool to simply generate image files in different dpis for different screen sizes: romannurik.github.io/AndroidAssetStudio/nine-patches.htmlMaxillary
T
22

use directly https://romannurik.github.io/AndroidAssetStudio/

For example, two devices that both report a screen size of normal might have actual screen sizes and aspect ratios that are slightly different when measured by hand. Similarly, two devices that report a screen density of hdpi might have real pixel densities that are slightly different. Android makes these differences abstract to applications, so you can provide UI designed for the generalized sizes and densities and let the system handle any final adjustments as necessary

You have to create different dimen , layout , images and icon files to support all devices.

changes in screen density.

xlarge screens are at least 960dp x 720dp
large screens are at least 640dp x 480dp
normal screens are at least 470dp x 320dp
small screens are at least 426dp x 320dp

Make this layout files, so that it will be same for all devices.

Give padding ,margin ,font and all properties as per devices.

res/layout/main_activity.xml           # For handsets (smaller than 600dp available width)
res/layout-sw600dp/main_activity.xml   # For 7” tablets (600dp wide and bigger)
res/layout-sw720dp/main_activity.xml   # For 10” tablets (720dp wide and bigger)

For Layout ,

res/layout/my_layout.xml              // layout for normal screen size ("default")
res/layout-large/my_layout.xml        // layout for large screen size
res/layout-xlarge/my_layout.xml       // layout for extra-large screen size
res/layout-xlarge-land/my_layout.xml  // layout for extra-large in landscape orientation

For Images

res/drawable-mdpi/graphic.png         // bitmap for medium-density
res/drawable-hdpi/graphic.png         // bitmap for high-density
res/drawable-xhdpi/graphic.png        // bitmap for extra-high-density
res/drawable-xxhdpi/graphic.png       // bitmap for extra-extra-high-density

For Icon

res/mipmap-mdpi/my_icon.png         // launcher icon for medium-density
res/mipmap-hdpi/my_icon.png         // launcher icon for high-density
res/mipmap-xhdpi/my_icon.png        // launcher icon for extra-high-density
res/mipmap-xxhdpi/my_icon.png       // launcher icon for extra-extra-high-density
res/mipmap-xxxhdpi/my_icon.png      // launcher icon for extra-extra-extra-high-density

For Launcher icon

36x36 (0.75x) for low-density
48x48 (1.0x baseline) for medium-density
72x72 (1.5x) for high-density
96x96 (2.0x) for extra-high-density
180x180 (3.0x) for extra-extra-high-density
192x192 (4.0x) for extra-extra-extra-high-density (launcher icon only; see note above)

Checkout Dimension and Supporting Multiple Screens Official Documentaion.

Tetrastichous answered 13/5, 2016 at 10:44 Comment(0)
P
7

Android Studio has a plugin called "Batch Drawable" install in your Android studio. This help to create images of different size.

Steps To import: File-->Settings-->Plugin-->Browse Repositories-->Click install button.

Restart your Android studio, then you will be able to find "Batch Drawable" inside the file menu of Android Studio.

Link: https://github.com/winterDroid/android-drawable-importer-intellij-plugin

Phalansterian answered 2/8, 2018 at 11:46 Comment(0)
F
1

There is no more you have to do, just put the different resolution files into different drawable-xxx file is okay. Remember that all the pics MUST HAVE the same name but Android will not automatically to match the screen size for each pic is the file name is not matched. Good luck!

Felspar answered 27/9, 2018 at 0:11 Comment(0)
K
0

put largescale image in drawable folder.

Kilkenny answered 13/5, 2016 at 10:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.