2

我跟着链接,但它不完美的工作..

主要代码

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();
    }

任何想法/建议将不胜感激..

4

0 回答 0