Can I programmatically set a wallpaper to not scro

2020-07-18 09:52发布

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.

标签: android
4条回答
The star\"
2楼-- · 2020-07-18 10:18

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.

查看更多
萌系小妹纸
3楼-- · 2020-07-18 10:30

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

查看更多
Lonely孤独者°
4楼-- · 2020-07-18 10:31

I'v fulfilled this feature by:

final WallpaperManager wpm = (WallpaperManager)getSystemService(
                Context.WALLPAPER_SERVICE);    
wpm.setWallpaperOffsetSteps(1, 1);
wpm.suggestDesiredDimensions(SCREEN_WIDTH, SCREEN_HEIGHT);
查看更多
▲ chillily
5楼-- · 2020-07-18 10:38

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.

查看更多
登录 后发表回答