¿Cómo escalar Live Wallpaper al tamaño de la pantalla?

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?


preguntado el 01 de febrero de 12 a las 03:02

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

if possible share your . or you will find vogella.de/articles/AndroidLiveWallpaper/article.html -

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? -

3 Respuestas

Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); 
width = display.getWidth(); 
height = display.getHeight();

contestado el 04 de mayo de 12 a las 07:05

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.

Respondido 08 Jul 12, 14:07

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.

Respondido el 13 de diciembre de 17 a las 04:12

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.