How to make full-screen images for various screen size in android?

3.4k views Asked by At

When we develop android apps, we put different size images to respective drawable folder for various screen resolution. For example, if I want to use 32x32 pixels image, I will make same image with different sizes like following.

24x24 ldpi
32x32 mdpi
48x48 hdpi
64x64 xhdpi
96x96 xxhdpi
128x128 xxxhdpi

It work perfectly for icons, sprites, etc. But now I want to make a background image to fit in all screen sizes and density. If I make an image with 320x480 (w x h) pixels and suppose I have 2 devices with normal dpi, 320x480 and 768x1024. The image will fit to screen in 320x480 device but I have no idea with latter because the image will not fit to all screen size unless it is 320x480 device.How to calculate size for my background image to fit in all screen sizes and resolution?

2

There are 2 answers

0
Mayank Jain On

Get highest resolution image and then upload it http://nsimage.brosteins.com it will down-sampled image for various screen sizes.

Support Different Pixel Densities https://developer.android.com/training/multiscreen/screendensities.html#TaskProvideAltBmp

0
PriyankVadariya On

simply give property to ImageView like

 <ImageView 
       .....
       android:scaleType="fitXY"
   />

but it will stretch Image, if you don't want to stretch your image then just use centerCrop , but it will crop image from side

 <ImageView 
           .....
           android:scaleType="centerCrop"
       />

scaleType will show your image in full size of ImageView