I'm working on a live wallpaper that changes a picture every few seconds. The "home screen" of the phone has more then just one screen. The user can scroll right and left to see additional app icons or widgets he/she has.
In the past, I had "static" wallpaper pictures that "spread" over ALL the "home" screens in a way that the user see a portion of the picture every time he/she scroll right or left. I'm trying to adjust my live wallpaper image to do the same thing but I'm unsuccessful.
Can you advise?
This is my code of drawFrame():
final SurfaceHolder holder = getSurfaceHolder();
Canvas c = null;
try
{
c = holder.lockCanvas();
c.drawColor(Color.BLACK); // clear the canvas
if (c != null)
{
c.save();
c.translate((float) mxOffset, 0);
if(myBg != null) {
float xScale = (float) c.getWidth() / myBg.getWidth();
float yScale = (float) c.getHeight() / myBg.getHeight();
c.scale(xScale, yScale);
c.drawBitmap(myBg, 0, 0, null);
//visible = true;
}
}
}
finally{
if (c != null) holder.unlockCanvasAndPost(c);
}
handler.removeCallbacks(runnable);
if (visible)
{
handler.postDelayed(runnable, 10000); // delay 10 sec
}
}