Android:在浏览五个主屏幕视图的同时移动背景图像

时间:2013-05-01 09:37:13

标签: java android android-canvas live-wallpaper

我希望在浏览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();
}               

0 个答案:

没有答案