我想在浏览 5 个主屏幕视图时移动背景图像。就像我们从图库中选择一张图片并设置为壁纸,然后它会随着主屏幕视图(偏移量)的变化而滚动。
SurfaceHolder holder = getSurfaceHolder();
Canvas canvas = null;
try {
canvas = holder.lockCanvas();
if (canvas != null) {
drawCircles(canvas);
}
} finally {
if (canvas != null)
holder.unlockCanvasAndPost(canvas);
}
绘图功能是
{
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();
}