image is strectching on the mutiple devices on Android phones - android

I'm developing the android app to display image banner when you open the app on android mobile.
The problem is, image banner is stretching on different android devices based on the resolution of the phone. This resulted, image-banner get too much stretched.
How to get Responsive image banner on Android app?

Take different size images in different drawable folders in res folder with same name.
There is a 3:4:6:8 scaling ratio in drawable size by DPI.
LDPI - 0.75x
MDPI - Original size
HDPI - 1.5x
XHDPI - 2.0x
XXHDPI - 3x
XXXHDPI - 4.0x
​
For example if a 100x100 image is a baseline (MDPI),
LDPI - 75x75
HDPI - 150x150
XHDPI - 200x200
XXHDPI - 300x300
XXXHDPI - 400x400
and so on.

Related

Designing icons for android

I did some research and found that there 6 different sizes required by Android to display images properly on all sorts of devices.
LDPI - 0.75x
MDPI - Original size
HDPI - 1.5x
XHDPI - 2.0x
XXHDPI - 3x
XXXHDPI - 4.0x
So suppose I have 100x100 image as a baseline (MDPI), then ldpi, hdpi, xhdpi, xxhdpi will be as follows.
LDPI - 75x75
HDPI - 150x150
XHDPI - 200x200
XXHDPI - 300x300
XXXHDPI - 400x400
But I have confusion as to what should be the baseline(mdpi). How do I select my baseline, does it have to be based on something? I can have different images in my app example a back arrow, home arrow, a background image(full screen), an Add icon and so on. But all these icons have to different sizes. So how can I choose my baseline size?
No need to choose, the mdpi(baseline) density means that one dp is roughly equal to one pixel. So we call it the baseline density.
If we provide icon with size by the definition. We will get all the icon image have same physical size on different density screen(ldpi,mdpi,xdpi and so on) with proper quality.
About the background image, I would recommend to put the background image to drawable-nodpi which the image just fill entire screen no matter the density, so just put it there to let the system don`t scale the image and save some memory resources to scale it.
reference Support different pixel densities
Check if this can help you,
Material design icons

Need advice for Android multiple resolution design

For example, I'd like to show an image in screen. Here are the size and dpi:
LDPI - 0.75x 75x75 120 dpi
MDPI - Original size 100x100 160 dpi
HDPI - 1.5x 150x150 240 dpi
XHDPI - 2.0x 200x200 320 dpi
XXHDPI - 3x 300x300 480 dpi
XXXHDPI - 4.0x 400x400 640 dpi
But the display for two devices is not what I want.
The first device is 480x800, 240 dpi. The second device is 800x1280, 213 dpi.The bigger screen has lower dpi. I need some advices on how to handle this case? Thanks
What I see is that your first device is a mobile while the second is a tablet. So you can provide alternate layout files for mobile's and tablets. See supporting multiple screens for more information. For this case for mobile you can use layout-sw720dp folder and for the bigger tablet screen. As for the images your current settings above will work great.

Scaling Images for mdpi

I am working on scaling images for my app to make them look great for every screen. I think I follow the different scales for mdpi, hdpi, xhdpi, xxhdpi, etc. The trouble I am having is that the smaller mdpi images are called for the 10.1" tablet making them appear far too small for the large screen size.
For example, I have a play button with the following sizes:
MDPI: 200px x 200px
HDPI: 300px x 300px
XHDPI: 400px x 400px
XXHDPI: 600px x 600px
And the 200px play button is being called to the 10" tablet.
What am I doing wrong? Thanks!
for tablet, the images has taken from drawable-xlarge folder.
The tablet has mdpi. if the image is not in xlarge folder, its get from mdpi folder.
So use xlarge folder.
http://developer.android.com/guide/practices/screens_support.html

Samsung Note 1 is Loading Resources From Xhdpi Folder

I am having this issue where I have HDPI and XHDPI folders in my eclipse project both have different images resolutions, both Images in the different folders are exactly the same but they differ in size.
So I lunched my app on Samsung Galaxy Note 1 which have 800 x 1280 pixels, 5.3 inches (~285 ppi pixel density) display, but it's loading drawables from the XHDPI folder.
I have tested that by modifying one image in HDPI folder and keep it as it is in the XHDPI folder, the result was note 1 is loading from the XHDPI folder, am I missing something here, it suppose to load images from the HDPI folder because it's screen density is smaller than 320 DPI.
You can check what density your device is set to with
Log.v(TAG, "density=" + getResources().getDisplayMetrics().densityDpi);
am I missing something here, it suppose to load images from the HDPI folder because it's screen density is smaller than 320 DPI
The maker of the device chooses which density bucket to use. Since ~285 is closer to 320 than 240, it is not surprising to me that Samsung chose -xhdpi. Others have reported that it indeed is an -xhdpi device.
If you are finding that -xhdpi resources result in slightly too large of images in certain places, you may need to control that in those places (e.g., set the ImageView size to the size that you want and set android:scaleType to be how you want the image to be adjusted).
it suppose to load images from the HDPI folder because it's screen density is smaller than 320 DPI.
why that?
HDPI is 240 ppi
XHDPI is 320 ppi
Note 1 has a 285 which is closer to XHDPI (|285-320|=35) than to HDPI (|285-240|=45)
On Android developer website, it says,
"hdpi Resources for high-density (hdpi) screens (~240dpi).
xhdpi Resources for extra high-density (xhdpi) screens (~320dpi)."
Any device which has a density higher than 240dpi should load layouts and images from xhdpi folder.
Thus, your app on galaxy note which has 285dpi loads images from xhdpi folder.

Images are shown big on AVD?

Well, I set my AVD to
480 x 800 resolution ,
abstracted lcd density to 320 pixel
And my image dimension is 207 width and 205 height and the image has set to 320 pixels per inch but it is shown very big on avd with resolution 480 x 800 and 320 dpi. Images are placed in #drawable/MDPI folder only. Here it is
Does image needs to set on 160 pixels per inch or I have to set avd size using (scale display to real size) option?
You have emulator of 320 dpi which is xhdpi. And you are putting your images in mdpi folder. Now when you launch your app it looks for images in xhdpi folder first and it finally load images from mdpi folder scale them to xhdpi density and show them. Thats why images are coming big.
May be you can test in mdpi density emulator or you can support xhdpi in your app by having images in xhdpi.
check with android:src="" and android:background="" attribute in xml file in the ImageView.

Categories

Resources