1

I'm working on my Live Wallpaper and I want it to scroll with the screen like a normal wallpaper does. I know I need to use onOffsetsChanged() but which parameter will tell me the direction that the home screen is being swiped? It seems like xOffset always returns a positive value no matter which way the screen slides.

Thank you.

Gilleland
  • 176
  • 3
  • 7

1 Answers1

4

The direction alone will not help you: you need to know the exact offset, because the user may have jumped several screens at once (e.g. by using a pop-up that displays mini-versions of all the home screens).

Generally speaking, you want to save the xPixel value you get in onOffsetsChanged, then use this to translate your canvas.

See my two answers below:
onOffsetsChanged: move Bitmap
android live wallpaper rescaling

Community
  • 1
  • 1
George Freeman
  • 2,260
  • 1
  • 15
  • 22