我对 Android 很陌生,但为什么我的图像没有显示在画布上?我知道它工作正常,因为背景颜色是黑色,我用相同的方法 onDraw 更改了它。谁能帮我?提前致谢!
public PongView(Context context) {
super(context);
paddle1 = BitmapFactory.decodeResource(getResources(), R.drawable.pongpaddle);
paddle2 = BitmapFactory.decodeResource(getResources(), R.drawable.pongpaddle);
}
protected void onDraw(Canvas canvas) {
xp1 = canvas.getWidth()/2;
xp2 = canvas.getWidth()/2;
yp1 = 25;
yp2 = 760;
canvas.drawColor(Color.BLACK);
canvas.drawBitmap(paddle1, xp1,yp1, null);
canvas.drawBitmap(paddle2,xp2,yp2, null);
Paint white = new Paint();
white.setColor(Color.WHITE);
canvas.drawText("Score P1:"+ p1Score +" P2: " + p2Score , 700, 20,white );
}