Android动态壁纸背景

时间:2011-11-25 13:41:32

标签: android live-wallpaper

如何在ACTION_MOVE事件上滚动背景图片?

以下是我用于绘制背景图片的代码:

void drawFrame() {
    final SurfaceHolder holder = getSurfaceHolder();

    Canvas c = null;
    try {
        c = holder.lockCanvas();
        if (c != null) {
            c.drawBitmap(myBg, 0, 0, mPaint);
        }
    } finally {
        if (c != null) holder.unlockCanvasAndPost(c);
    }

    // Reschedule the next redraw
    mHandler.removeCallbacks(mDrawAnim);
    if (mVisible && mAnime) {
        mHandler.postDelayed(mDrawAnim, 50 );
    }
}

0 个答案:

没有答案