when we scroll, the foreground of the home screen (icons, widgets, etc.) moves to the left or right by the full screen width, but the background image (or live wallpaper) only moves by a fraction of that width. My question is how get this effect. till now have done this.
SurfaceHolder holder = getSurfaceHolder();
Canvas canvas = null;
try {
canvas = holder.lockCanvas();
if (canvas != null) {
drawCircles(canvas);
}
} finally {
if (canvas != null)
holder.unlockCanvasAndPost(canvas);
}
the draw function is
{
private void draw(Canvas canvas) {
Paint paint = new Paint();
DisplayMetrics metdisplayMatrics = new DisplayMetrics();
Display display = ((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay();
display.getMetrics(metdisplayMatrics);
canvas.save();
canvas.drawColor(0xff000000);
mRecscreenRectangleFrame = new Rect(0, 0, (int) (metdisplayMatrics.widthPixels*2.0), metdisplayMatrics.heightPixels);
photo1= BitmapFactory.decodeResource(getResources(), R.drawable.img1);
canvas.drawBitmap(photo1, null,mRecscreenRectangleFrame, paint);
photo1.recycle();
System.gc();
}
Now how to put live wallpapers parallax-scrolling effect.
@Override
public void onOffsetsChanged(float xOffset, float yOffset,
float xOffsetStep, float yOffsetStep, int xPixelOffset,
int yPixelOffset) {
super.onOffsetsChanged(xOffset, yOffset, xOffsetStep, yOffsetStep,
xPixelOffset, yPixelOffset);
WallpaperManager myWallpaperManager = WallpaperManager.getInstance(getApplicationContext());
View view=new View(getBaseContext());
myWallpaperManager.setWallpaperOffsets(view.getWindowToken(),xOffset, 0f);
}
Not working yet.................