0

I'm drawing a bitmap on a SurfaceView using Canvas.drawBitmap(). I have the bitmap in the res/drawable folder and it seems to scale the bitmap correctly on all devices.
Some users have complained that when they change their device's screen density (using a rooted program called LCDDensity Changer) the bitmaps do not scale accordingly. A large bitmap will get squished as if it is still looking for the old density.

Is there a way to handle density changes when users use programs like LCD Density Changer?

Other info:
1. minSDKVersion=3
2. no targetSDKVersion is set
3. I use getMetrics() to determine screen height and width
4. I'm not using the drawable-hdpi, ldpi, etc folders

alain.janinm
  • 19,951
  • 10
  • 65
  • 112
FoppyOmega
  • 447
  • 1
  • 4
  • 17
  • As changing the device density is not supported natively, I think that you should not support it. – clemp6r Jan 07 '12 at 21:10

2 Answers2

0

One approach,I think you need to use hdpi, ldpi etc., Here is an article on how to do that.Android densities

Second approach, you may get screen density prgormatically using DisplayMetrics class and have different images for each density. Here is SO discussion on get screen density

DisplayMetrics metrics = new DisplayMetrics(); 
getWindowManager().getDefaultDisplay().getMetrics(metrics);
Community
  • 1
  • 1
kosa
  • 65,990
  • 13
  • 130
  • 167
0

I had multiple problems here. I was targeting v1.5 and I've been using hardcoded constants for screen locations without including a bounding rectangle.

I'm going to:
1. Switch to 2.2 framework (which has better compatability with screen resolutions and densities
2. Use "drawBitmap(Bitmap bitmap, Rect src, Rect dst, Paint paint)" rather than "drawBitmap(Bitmap bitmap, float left, float top, Paint paint)". This allows me to specify exactly where I want a graphic drawn and it will scale accordingly.
3. Start using the ldpi, hdpi, xhdpi, etc folders. I'm also considering just using the hdpi folder and allowing other devices to scale the images down. (I wouldn't use xhdpi because I read somewhere that it is only supported in gingerbread 2.3).

FoppyOmega
  • 447
  • 1
  • 4
  • 17