如何使用动态壁纸滚动图像?

时间:2013-02-03 14:59:16

标签: android live-wallpaper

我跟着link,但它没有完美地工作..

主要代码

private void drawFrame() {
        final SurfaceHolder holder = getSurfaceHolder();
        Canvas c = null;

        try {
            c = holder.lockCanvas();

            if (c != null) {

              c.save();
              c.translate((float)x_offcet,0);

                if (backgroundBitmap != null) {

                    c.drawBitmap(backgroundBitmap, 0, 0, null);

                }
               c.restore();
            }

        } finally {

            if (c != null) {
                holder.unlockCanvasAndPost(c);
            }
        }

        mHandler.removeCallbacks(run);

        if (visible) {
            mHandler.postDelayed(run, INTERVAL);
        }
    }

   @Override
    public void onOffsetsChanged(float xOffset, float yOffset,
            float xOffsetStep, float yOffsetStep, int xPixelOffset,
            int yPixelOffset) {

         x_offcet = xPixelOffset;

         drawFrame();
    }

任何想法/建议都将受到高度赞赏..

0 个答案:

没有答案