I have develop a simple application and compile it with screen resolution 480*800 mdpi emulator.It shows all images perfectly placed on screen.
I have added images only in drawable folder.
But when i try the same application with 480*800 hdpi emulator the images looks big on the screen and all alignment gets distracted.
Do I need the different image size for mdpi and hdpi pixel density for same screen resolution i.e 480*800 also?
Thanks.
Yes. For different screen densities, you should provide appropriately scaled bitmaps.
This way they will look the best on all devices, without Android having to scale them.
This link should provide you with important information to get started:
http://developer.android.com/training/basics/supporting-devices/screens.html
Related
I am making an app for Android and I am having trouble providing the right resources to the right dpi-folders to make the resource look sharp and not pixelated. I have already made different resources for every folder and they look sharp on my LG G5 but when I am loading the app to my tablet the pictures are smaller and not that sharp.
I am just gonna put the sizes of the different image sizes in here so that no one asks:
mdpi - 54x47 | hdpi - 81x70 | xhdpi - 108x94 | xxhdpi - 162x141
My Tablet uses xhdpi resources and my phone uses xxxhdpi resources.
I've wanted to redo all images so that they would be as sharp as possible. So I took a ruler and messured the size of the image as it should appear on the screen and multiplied it with the dpi to calculate the size of the image.
I came up with this width for the Tablet:
0.866in * 320dpi = 277px
But when I checked and calculated the width of the image for the phone, I got this:
0.413in * 640dpi = 264px
At this point I was confused because the width for the hdpi was larger than the one for the xxxhdpi.
I know that if i had a tablet with 640dpi i would get a image that is bigger than the one with 320dpi, but I still don't know what size the image should be.
Is there maybe another way to categories the images? I saw that screens have different screen sizes (small, normal, large, xlarge), but as far as I know they only determine the layout size. Can anyone help me get sharp images?
I think you have not added image resources for the tablet. For tablet image resources you need to create 5 more folders in your res directory that is
mipmap-sw450dp-mdpi
mipmap-sw450dp-hdpi
mipmap-sw450dp-xhdpi
mipmap-sw450dp-xxhdpi
mipmap-sw450dp-xxxmdpi
For more information please read this.
I'm new to Android and I'd like to know why those images I put in hdpi, ldpi, mdpi, xhdpifolders are not actually responding to what I want.
In hdpi, I put images that are fit for big screens.
In ldpi, for small screens, in mdpi for normal screens and for xhdpi for tablets.
But I wonder why it's still not displaying the correct images for big screens. It looks like small images (that are fit for small screens) on the screen. I have named the images exactly the same. What is wrong with this?
I need your suggestion. Help is much appreciated. Thanks in advance.
I think that you don't have the problem in the code, nor in the images, but in the devices you're using to try the different densities. If you are assuming that larger screens means higher densities, that is not always the case. Note that hdpi, ldpi, mdpi and xhdpi refer to density, not screen size.
For example, below you can find two screenshots of the same ImageView pointing to the same #drawable/a icon but deployed in two devices with different screen density. To make the point I have placed completely different icons (both with the same name a.png) in each density folder so that the difference can be easily appreciated:
2.7" - ldpi 3.7" - hdpi
I want to make my application to multiple screen support. so to achieve this i read the Android developers guildeline https://developer.android.com/guide/practices/screens_support.html and i have created the different drawable and layout folders to put different size of images.
I tested the application in different devices and it looks fine in those devices, while i found that in one of 7" tablet the images are too small. to confirm this i created simple project and put same name of images in different folder and found that this device uses ldpi drawables and in generally the size of ldpi drawable used to be 36x36 and that causes the issue, if i increase this drawable size then it will not compatible with other low-density devices.
Here is the Dispaly Metrics of the device in which i am having a problem.
{density=0.75, width=800, height=444, scaledDensity=0.75, xdpi=160.0, ydpi=160.42105}
How to deal with this problem ? if anyone have this issue before then please give me some advice. any idea and help will be appreciated.
Thanks & Regards
You can get more control over this:
Specify multiple different images for different screen resolutions and densities. To do so read supporting multiple screens. If you need even more precision in image scaling and quality you can use the fundamental size of screen attribute which is sw<N>dp - you can specify the smallest width of the screen where your image should be used. This is a qualifier name for a resource folder.
Some values you might use here for common screen sizes:
320, for devices with screen configurations such as:
240x320 ldpi (QVGA handset)
320x480 mdpi (handset)
480x800 hdpi (high density handset)
480, for screens such as 480x800 mdpi (tablet/handset).
600, for screens such as 600x1024 mdpi (7" tablet).
720, for screens such as 720x1280 mdpi (10" tablet).
Just specify your device width and put your edited image that fits the best in corresponding sw<N>dp folder in your case sw<444>dp.
You should also have a look at other qualifiers that make Android choosing image at runtime (screen density, Available width, Available height, Screen size or Screen aspect). By combining these qualifiers and testing carefully you will be sure that the user has the best experience on each device.
Shortly, put your image under drawable-sw<444>dp folder. (444-smaller screen metric)
In my application i'm using a background image with some text in it, it's size is 800x1280 (portrait mode)
When running the app on mobile devices , the background image looks great.
When running the app on tablet .. let's say Galaxy tab 10.1 you can see that the text in the background image is a little blurred and little pixeled..
it seems like if the image was smaller than the device resolution and got stretched.. only that image is already in the device resolution
What am i missing ?
Thanks
Your drawable folder contains folders ldpi, mdpi, hdpi, xhdpi - it's for different density per inch.
I suppose your mobile device uses mdpi or hdpi, while tablet uses xhdpi.
To get the best perfomance I recommend you to put 4 different sizes of your image to these folders. The sizes should be 0.75 x ORIGINAL_SIZE for ldpi, ORIGINAL_SIZE for mdpi, 1.5 x ORIGINAL_SIZE for hdpi, 2 x ORIGINAL_SIZE for xhdpi
update: tablets are hdpi, not xhdpi
Your device may be scaling the image somehow. Do you have your image in res/drawable? Try putting it in drawable-hdpi, drawable-mdpi and drawable-xhdpi also. This way it should pick the image fitting your resolution and refrain from scaling anything.
Note that you may want it to be scaled on other resolutions, so putting up different resolutions for different dpis is probably wise. But this is a good way to see if this is indeed the problem.
First of all, did you put your background image to specified drawable folders? :) Your image can be scaled.
If You're using linearlayout, you can check another solution, put imageview and layout into framelayout :)
Here you got examples:
android-scale-a-drawable-or-background-image
scale-background-image-in-linearlayout
:)
I need explanations.
I develop an application running for Honeycomb on a tablet 10.1.
I set an image 796x1228 pixel in drawable-xhdpi folder. When this image is called directly it displayed on 1/4 of screen size. If I set this image in a layout taking all screen width and height, it scales and result is not clean.
I search a long time before testing to put this same image in drawable-mdpi folder and get a good display.
The Android documentation says that for screen xhdpi we have to put our images in a folder xhdpi, but results is really bad.
Where is my trouble ? Thanks for your explanation, information...
A 10.1" Honeycomb tablet is not xhdpi. It's an xlarge display, which is completely different. The XOOM for instance has an xlarge, mdpi display.
Are you sure your device's screen is xhdpi? Usually, devices with big screens are something like xlarge, mdpi or hdpi.
If you want just to show an image on a view you can put it into drawable-nodpi, load it and apply to your view (or let the app do it automatically).