Making android live wallpaper with parallax scrolling
<p>I'm creating a live wallpaper with parallax scrolling. I've read the article: <a href="http://stackoverflow.com/questions/5044363/parallax-effect-scrolling-of-live-wallpaper-background">Parallax effect scrolling of live wallpaper background</a>. But when I change desktops the background moves wrong way (If I change desktop from left to right, picture moves from right to left). How to change direction?
Code snippet:</p>

<pre><code>public void Init(Bitmap bitmap){
  bg = new BitmapFactory().decodeResource(context.getResources(), R.drawable.thunder);
  bg = Bitmap.createScaledBitmap(bg, (int)(width*1.4), height, true);
}

float dx = 0.0f; 
@Override
    public void onOffsetsChanged(float xOffset, float yOffset,
            float xStep, float yStep, int xPixels, int yPixels) {
        dx = (width - bg.getWidth()) * (1 - xOffset);
    } 

private void doDraw(Canvas canvas) {
    canvas.save();
    canvas.translate(dx, 0);
    canvas.drawBitmap(bg, 0, 0, null);

    canvas.restore();
}   
</code></pre>
