Android 如何通过动态编码设置背景
我曾经画过背景,但我想把它画成可画的/图片背景,而且背景是错误的,我该怎么做Android 如何通过动态编码设置背景,android,Android,我曾经画过背景,但我想把它画成可画的/图片背景,而且背景是错误的,我该怎么做 public void surfaceCreated(SurfaceHolder arg0) { Bitmap background = BitmapFactory.decodeResource(context.getResources(), R.drawable.download); float scale = (float)background.getHeight()/(float)
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);
}
那么你到底想做什么?他给了我错误的方法,它给了你什么?你想不想得到答案?