Search code examples
androidmanifestswipewallpaperlive-wallpaper

Activity UI on top of the current Android live wallpaper - how to have left or right swipes handled like on Android desktops?


I'm trying to create my activity's view on top of the current system wallpaper by setting

<activity android:theme="@android:style/Theme.Wallpaper.NoTitleBar">

or

<activity android:theme="@android:style/Theme.Holo.Wallpaper.NoTitleBar">

in the Android manifest file.

However, when I'm on Android desktop and have a live wallpaper, if I swipe right or left to another desktop, the wallpaper changes (to look like it's displayed from the right of from the left). [NB: this effect is called "parallax scrolling."]

I don't get this behavior in my application, although other touch events (taps, etc.) are sent to the live wallpaper.

How can I get the default Android behavior in my application?


Solution

  • Live wallpapers generally do not trigger scrolling in response to onTouchEvent(). Instead, the live wallpaper programmer usually simplifies his life by processing onOffsetsChanged() events, which are sent by the launcher in any of a variety of situations: side swipes, touching one of the little scroll dots, etc.

    Your only possibility would be for your app to intercept the swipe, convert it to an onOffsetsChanged() event, and then call the WallPaperService.Engine. I've never seen anyone try to do this, and it's not what I would call trivial, but it's worth a shot. :-)