我已经解决了这个问题一个星期了,我知道它的东西太傻了。当我在手机或模拟器上运行我的应用时,正在绘制的位图重叠。对不起我的语法和我的问题,但这里的代码和模拟器的屏幕截图。
//How I am rendering / drawing the bitmaps
public void render() {
if (gameHolder.getSurface().isValid()) {
gameCanvas = gameHolder.lockCanvas();
gameCanvas.drawColor(Color.BLACK);
int w = gameCanvas.getWidth();
int h = gameCanvas.getHeight();
Log.i("measure", w + " | " + h);
gameCanvas.drawBitmap(loadInBitmaps(1), (w / 2), h / 2, gamePaint);
gameCanvas.drawBitmap(loadInBitmaps(2), (w / 2) + 32, h / 2, gamePaint);
gameHolder.unlockCanvasAndPost(gameCanvas);
}
}
//How I am loading in the bitmaps
public Bitmap loadInBitmaps(int number) {
Bitmap loadedBitmap = null;
if (number == 0) loadedBitmap = null;
//UI Bitmaps
if (number == 1)
loadedBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.northbutton);
if (number == 2)
loadedBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.southbutton);
return loadedBitmap;
}
答案 0 :(得分:1)
因为您将drawables放在默认的 drawable 目录中,所以Android假定您的Bitmap需要从默认的mdpi大小缩放。 如果要禁用资源缩放,请将您的drawable放在 drawable-nodpi 中。