xhdpi scales images - android

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).

Related

What size of an image should I use to get sharp images?

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.

Why 4" and 5" screen not showing images properly

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

android, graphic design get blurred on tablets

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
:)

Automatic layout adjustment

In the beginning I created my application to work on all resolutions, tested on my phone with small screen and large screen tablet.
As I had created the images for drawable-hdpi, MDPI, ldpi, each image with its resolution, he was adjusting.
However now I'm testing again on the tablet and the resolution cell is small, is only correct for the phone, she stopped to adjust the tablet increased.
Do not know if it was some setting I made in layout,
I'm using relative layout, fill_parent and wrap_content.
And in some cases put margin, and alignment, below ...
Anyone know tell me how to adjust automatically, or imagine what might be wrong?
I think you missed something about density.
Image auto scaled by os with density, as an example in lower density Image will be scaled smaller.
As lulumeya said this is for sure problem of density of tablet you are using to test
For tablet instead of putting images in "drawable-hdpi" or "drawable-xhdpi" for large screens,
put them into folder named "drawable-xlarge" in /res folder.
This folder will be used for
large screen devices such as tablets.

Can't get drawables resolution right for Android tablets

I use .png as a background for a custom button that I declare in XML like this
android:background="#drawable/samplepng"
But I can't get the resolution right for tablet screens :
For example, my ressource is a 200x200 pixels .png (initially designed for iOS and retina)
I place a 100x100 px version in the drawable-mdpi folder and a 200x200 px version in the drawable-xhdpi folder.
I also need to have a layout for a typical 320x480 screen in the layout folder and another layout for 10" tablets in the layout-xlarge folder.
The size of the button is 100x100 dp in the normal layout and 200x200 dp for xlarge layout, so that it looks right.
With the Android emulator, a 10" tablet uses mdpi ressources and xlarge layout.
As a result, the button background is drawn with a scaled version of the 100x100 image which looks very blurry, as opposed to the crisp 200x200 original image.
If I don't use a mdpi ressource, it looks blurry just as well.
Am I doing something wrong ? is it only an emulator problem and it looks nice on a real device ?
Please help, I read 10 times google's doc but can't find an answer.
If you don't launch the emulator with 'Scale display to real size' checked, then it will always use mdpi drawables.
See here for more.
Your issue might be in the android version your targeting. Try switching the emulator to android 3.0 and 3.1.

Categories

Resources