0

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

ibm123
  • 1,214
  • 2
  • 15
  • 39
  • 1
    You have to use different images for different screen resolution.. and put those images in resource folders like drawable-hdpi, drawable-xhdpi etc.. – user370305 Sep 11 '12 at 09:29

3 Answers3

1

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

user1049280
  • 5,176
  • 8
  • 35
  • 52
  • How do i determine what is the original size ? – ibm123 Sep 11 '12 at 09:51
  • you say "mobile device uses mdpi or hdpi, while tablet uses xhdpi" That's not true , tablets are hdpi not xhdpi – ibm123 Sep 11 '12 at 09:54
  • you are right, tablets are hdpi, my fault. original size is the necessary size of the image. For example I draw 1:1 design of my app in Inkscape - all icons in it has original size – user1049280 Sep 11 '12 at 10:05
0

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.

Mark Gjøl
  • 1,845
  • 12
  • 21
0

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

:)

Community
  • 1
  • 1
Peter Moskala
  • 360
  • 1
  • 9