6

I am writing an app that allows a user to set the phone's wallpaper from a list of pictures. By default it scrolls across the multiple home screens. I want the wallpaper on the home screen to be a static non-scrolling image.

What can I do programmatically to achieve this? Is this even possible?

I am using wallpaperManager.setResource(...); to set the wallpaper.

I've also tried wallpaperManager.setWallpaperOffsetSteps(0,0); but that did not solve my problem.

Jasper
  • 2,166
  • 4
  • 30
  • 50
bims
  • 63
  • 1
  • 3

7 Answers7

11

I'v fulfilled this feature by:

final WallpaperManager wpm = (WallpaperManager)getSystemService(
                Context.WALLPAPER_SERVICE);    
wpm.setWallpaperOffsetSteps(1, 1);
wpm.suggestDesiredDimensions(SCREEN_WIDTH, SCREEN_HEIGHT);
herbertD
  • 10,657
  • 13
  • 50
  • 77
  • 1
    This is a workaround. In my tests, the wallpaper started scrolling again after the device was rotated or restarted. – Twinsen Jan 15 '14 at 15:56
4

This is controlled by the Launcher application. If you want a non-scrolling wallpaper, install a Launcher app that doesn't scroll the wallpaper :)

Romain Guy
  • 97,993
  • 18
  • 219
  • 200
  • can I somehow change the live wallpapers programmatically? Can you please check this one? http://stackoverflow.com/questions/13683464/set-live-wallpaper-programmatically-on-rooted-device-android – Naskov Dec 06 '12 at 12:36
2

Normally ImageWallpaper's size is set double wider than display's width so when you scroll home left or right, ImageWallpaper handles offsetchange events.

I've not tried this, but it may work i think. You may try this: [suggestDesiredDimensions]: http://developer.android.com/reference/android/app/WallpaperManager.html#suggestDesiredDimensions(int, int)

Set dimensions same as your workspace's width.

theWook
  • 843
  • 9
  • 22
2

In case you do not know the screen width and screen height while setting wallpaper, this might help (P.S It is in Kotlin)

 val manager = WallpaperManager.getInstance(context)
 val drawable = manager.builtInDrawable
 manager.setWallpaperOffsetSteps(1F, 1F)
 val height = drawable.intrinsicHeight
 val width = drawable.intrinsicWidth
 val scaledBitmap = Bitmap.createScaledBitmap(bitmap, width, height,true)
Abhilash
  • 61
  • 5
1

If you want to put some effort into a solution, you could create a live wallpaper which displays a static, user-selectable image. Then your wallpaper could override the offset changes if that's what is desired. That's a lot of work, though, to stop the scrolling effect.

Alternatively, you could crop the image to the screen's size before setting it to wallpaper. That would stop the scrolling, but would break screen orientation changes.

Josh
  • 10,618
  • 2
  • 32
  • 36
  • Agree live wallpaper is too much. I tried setting a wallpaper sized to the fit the screen (e.g 480 x 854) on the Droid. The image is stretched (960 x 854) to fit across the 5 screens that u can scroll thru - is that what u were suggesting? Not sure. Thanks – bims Oct 15 '10 at 15:12
  • Oh, I didn't realize that the cropped image would be auto-stretched to fit the screen-switching model. That IS what I was suggesting. You probably didn't want this solution either, though, because changing orientation would have screwed up your image dimensions. Looks like Romain had the right of it (as usual). – Josh Oct 15 '10 at 15:30
1

can you try

final WallpaperManager wpm = (WallpaperManager)getSystemService(
                Context.WALLPAPER_SERVICE);    
wpm.setWallpaperOffsetSteps(1, 1);
wpm.suggestDesiredDimensions(SCREEN_WIDTH, SCREEN_HEIGHT);
Ole Pannier
  • 3,208
  • 9
  • 22
  • 33
1

For extremally decrease scrolling just crop a bitmap to device screen ratio, for example 9*16 and set this bitmap by wallpaper manager, but it works for one screen orientation (it is OK for smart phones). Other solutions do not work.

Style-7
  • 985
  • 12
  • 27