如何通过动态编码设置背景

时间:2014-05-05 12:53:32

标签: android

我曾经画过背景但是我想让它成为可绘画/图片背景而错误的背景我该怎么办?

public void surfaceCreated(SurfaceHolder arg0) {
        Bitmap background = BitmapFactory.decodeResource(context.getResources(), R.drawable.download);
        float scale = (float)background.getHeight()/(float)GetHeight();
        int newWidth = Math.round(background.getWidth()/scale);
        int newHeight = Math.round(background.getHeight()/scale);
        scaled = Bitmap.createScaledBitmap(background, newWidth, newHeight, true);

    }
public void onDraw(Canvas canvas) {
    canvas.drawPicture(mbgdDrawable);// draw the background
}
public void DrawBackground(Canvas canvas) {
    canvas.drawBitmap(scaled, mScreenHeight, mScreenWidth,null);
}

0 个答案:

没有答案