using onOffsetsChanged() to get home screen swipe direction

后端 未结 1 1572
广开言路
广开言路 2020-12-06 15:39

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 tel

相关标签:
1条回答
  • 2020-12-06 16:12

    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

    0 讨论(0)
提交回复
热议问题