bims
bims

Reputation: 63

Can I programmatically set a wallpaper to not scroll?

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.

Upvotes: 6

Views: 8778

Answers (7)

Style-7
Style-7

Reputation: 1226

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.

Upvotes: 1

Abhilash
Abhilash

Reputation: 89

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)

Upvotes: 2

ismail maaitat
ismail maaitat

Reputation: 11

can you try

final WallpaperManager wpm = (WallpaperManager)getSystemService(
                Context.WALLPAPER_SERVICE);    
wpm.setWallpaperOffsetSteps(1, 1);
wpm.suggestDesiredDimensions(SCREEN_WIDTH, SCREEN_HEIGHT);

Upvotes: 1

herbertD
herbertD

Reputation: 10965

I'v fulfilled this feature by:

final WallpaperManager wpm = (WallpaperManager)getSystemService(
                Context.WALLPAPER_SERVICE);    
wpm.setWallpaperOffsetSteps(1, 1);
wpm.suggestDesiredDimensions(SCREEN_WIDTH, SCREEN_HEIGHT);

Upvotes: 11

theWook
theWook

Reputation: 843

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.

Upvotes: 2

Josh
Josh

Reputation: 10738

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.

Upvotes: 1

Romain Guy
Romain Guy

Reputation: 98511

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

Upvotes: 4

Related Questions