3

I have been working on creating a live wallpaper lately by placing a bitmap image on a canvas. I created the images to fit a screen size of 480x800. The problem is that when I load the live wallpaper onto a tablet or larger screen size it does not fill the whole screen, or scale at all.

I have tried using DisplayMetrics but I havent been able to get it to work within the life wallpaper class. Any ideas on how I can scale images to fit the screen size within a live wallpaper?

Thanks!

ramayac
  • 5,173
  • 10
  • 50
  • 58
Gatekeeper
  • 6,708
  • 6
  • 27
  • 37
  • 1
    I think your real question is "how to get the size of the screen", isn't it? Why can't you use the `DisplayMetrics` in the live wallpaper class? I think it's feasible. – Huang Feb 01 '12 at 03:47
  • if possible share your . or you will find http://www.vogella.de/articles/AndroidLiveWallpaper/article.html – NovusMobile Feb 01 '12 at 10:43
  • 1
    DisplayMetrics does not seem to be allowed in the WallpaperService class. Does anyone possibly have an example of how to scale a live wallpaper to different screen sizes? – Gatekeeper Feb 03 '12 at 03:41

3 Answers3

2
Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); 
width = display.getWidth(); 
height = display.getHeight();
Perception
  • 79,279
  • 19
  • 185
  • 195
Alex
  • 36
  • 2
0

You need to scale your bitmap according to width and height of wallpaper. You can get width and height in onSurfaceChange() method. And yes dont forget to multiply your width with 2 to make parallax scrolling.

Ravi Bhojani
  • 1,032
  • 1
  • 13
  • 24
0

Try not to use the " size(); " command. Use " fullScreen(); " it will adapt your wallpaper to the screen size of whatever device it's running on.

You can also use " displayWidth " and " displayHeight " anywhere in your code to help.