Code example for PaintDrawable

Methods: setBounds

0
 
	private void createBackground() { 
		// Adjust width/height to game ratio to avoid invisible walls 
    	Rect bounds = new Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
 
		mBackground = new PaintDrawable(0xff000000);
		mBackground.setBounds(bounds);
	} 
	 
	private void updateGraphics(Canvas canvas) {
		mBackground.draw(canvas);
		canvas.drawBitmap(beer, SCREEN_WIDTH/2 - 38, 10, null);
		ship.draw(canvas);
		ob1.draw(canvas);
		ob2.draw(canvas);
		 
	} 
		 
	private void resetGraphics(Canvas canvas) {        
		ship.setBounds(SCREEN_WIDTH/2 -25,SCREEN_HEIGHT - 100,SCREEN_WIDTH/2 + 25,SCREEN_HEIGHT - 50);
	    updateGraphics(canvas);