Images are shown big on AVD? - android

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.

Related

If I have an image 50dp wide/tall in xhdpi, what size do I make for mdpi?

I am working with a graphic designer at the moment who is trying to verify what sizes images I am currently using in my app so he can create new images in the right size for all resolution modes (designing the image at the smallest size and then scaling it for the other modes).
In my app, I am emulating a device that is 720 x 1280: xhdpi, and on this device, an ImageView is set to size 50dp x 50 dp.
Is it correct to say 50 dp xhdpi -> 25 dp mdpi? 100px? Or 50px? What exactly? What is the correct size that we should be making for the smallest size?
According to Android Documentation.
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
According to the upper difference you can calculate the ImageSize resoultion.
Update :
you have create different size of Image like HDPI, MDPI, XHDPI. but that is not mean that you can set ImageView Height and Width according to it's Drawable.
Example :
let's some device have small screenSize but it is high density support so you have to set high resolution density Image but the Size of the ImageView you have create small in that case.

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.

Android image resource and need for 10 images to cater for each screen resolution and orientation

I'm a beginner developing an Android app that needs to display a clip art type png image the full width of the screen in both portrait and landscape mode:
Portrait:
Landscape:
Would I be right in saying that in order to cater for each screen resolution and orientation I need to include the following image sizes?:
Image width: Resource folder:
xxhdpi – 1920 px drawable-land-xxhdpi
xhdpi – 1280 px drawable-land-xhdpi
xxhdpi – 1080 px drawable-xxhdpi
hdpi – 960 px drawable-land-hdpi
xhdpi – 720 px drawable-xhdpi
mdpi – 640 px drawable-land-mdpi
hdpi – 540 px drawable-hdpi
ldpi - 480 px drawable-land-ldpi
mdpi – 360 px drawable-mdpi
ldpi - 270 px drawable-ldpi
This seems overkill. The App could have a thousand of these images and thats 10 versions of each.
What is the normal approach in this scenario?
Would you scale the images to suit?
Assuming you will maintain the same aspect ratio regardless of whether the screen is in portrait or landscape orientation and you will be displaying the image via an ImageView, you will only need 4 versions of each image - xxhdpi, xhdpi, hdpi, and mdpi.
As far as the image widths go, stick with the 2:3:4:6:8 scaling ratio recommended here, in the Android Documentation. That link specifically discusses icons, but the scaling ratio holds true for all images. So if you are using an image width of 640 px in landscape on mdpi, the hdpi, xhdpi, and xxhdpi should have widths of 960 px, 1280 px, 1920 px, and 2650 px, respectively. Don't worry about a ldpi version because Android will scale down the hdpi version for low resolution devices.
Last thing, set the scale type of the ImageView to a scale type which will maintain the image's aspect ratio (CENTER_CROP or CENTER_INSIDE). See the ImageView documentation for info about setting the scale. Then once you set the image to fill up the width of the screen, the image should appear as you would like.

How to implement an application to take image from appropriate folder?

i am working on an android app. as this should be all screen size supportive .but it is not working properly.
I can I set that for 480*800 size it will take images from drawable-hdpi folder?
Screen size and dpi aren't the same thing. DPI is the number of pixels per inch. a 480x800 screen can still be any dpi level- it would just be a smaller screen with higher dpi.
You can try doing a size override with drawable-swNdp where N is a pixel value. That works for layouts, I believe it also works for drawables.
To support on all resolution devices put different resolutions images in different folders in drawable as,
drawable-ldpi - 240 * 380
drawable-mdpi - 320 * 480
drawable-hdpi - 480 * 800
drawable-xhdpi - 720 * 960
For more info about resolution refer this link :
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.

Categories

Resources